Multiple left-hand-side partial assignment in Matlab -


consider following matrix:

a=[1,2,3] 

therefore

size(a)=[1,3] 

i want assign second dimension 3 variable n. efficient way?

why following not working?

[[],n]=size(a) 

or

  n= num2cell(size(a)){2} 

this simplest, , works a number of dimensions:

n = size(a,2); 

if a guaranteed have 2 dimensions, use

[ m, n ] = size(a); 

and if don't need first variable, in recent versions of matlab can write

[ ~, n ] = size(a); 

as things have tried:

  • [[],n]=size(a) not work because [] not variable can assign anything.

  • n= num2cell(size(a)){2} not work because can't directly index in matlab. need temporary variable: temp = num2cell(size(a)); n=temp{2}. or dispose of num2cell , do: temp = size(a); n=temp(2).


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -