What are the differences between these array definitions in MATLAB?
I am trying to understand the differences between these array definitions:
abc=[ 0 0 0 0 0 0]
and
abc=[0;0;0;0;0;0]
In C, first 开发者_开发技巧definition is
int abc[]={0,0,0,0,0,0};
second definition is
int [6][1]= {{0},{0},{0},{0},{0},{0}};
Am I correct about that?
abc = [1 2 3 4]
Is a "row vector".
abc = [1 2; 3 4]
Is a 2x2 matrix, because semicolons inside brackets separate rows.
abc = [1; 2; 3; 4]
Is a 4x1 matrix, aka "column vector". It's a special case of a matrix, really. You can also get it by transposing the corresponding row vector:
abc = [1 2 3 4]'
(note the quote at the end - this is the transpose)
P.S.: Yes, your interpretation to C is correct in this case.
精彩评论