What is the meaning of y{1,2} in matlab?
7 views (last 30 days)
Show older comments
SUBHAMITRA PATRA
on 4 Sep 2017
Commented: Image Analyst
on 9 Sep 2017
I have done 100 regressions by using loop command and there, for dependent variable i have given command that, y{i}=file{1,i}(:,3);
That means, 3rd column is the dependent variable in each sheet. But when i am entering it, the value of y{1,1} remained same, but the value of y{1,2} and the rest which is expected to be the dependent variable for the next sheet is changing. Therefore, i want to know what is the meaning of y{1,2}, y{1,3} and so on.
So that i can able to rectify that the whether the value of y{1,2} gives the picture of dependent variable in the 2nd sheet and similarly, y{1,3} gives the picture of DV in the 3rd sheet and so on or not?
0 Comments
Accepted Answer
Image Analyst
on 4 Sep 2017
You have a cell array that you loaded up with vectors that are the third column of a file.
y{i}=file{1,i}(:,3);
So this is a 1-D cell array - a row vector of cells. So if you do y{1,2} or y{1,3} you are getting the contents of the cell in row 1 and column 2 or 3. However since there is only one row, the 1 is unnecessary. So, for this particular shape of y (a row vector), y{1,col} is the same as y{col}.
If you did y{145, 3} you'd get an error because there are not 145 rows in y, there is only a single row of cells.
It's the same with any array, even doubles. If you have a double row vector, rowVec(1, col) is the same as rowVec(col), and if you have a column vector, you can specify the column as 1 and it's the same (but unneeded) so colVec(row, 1) = colVec(row). The 1 is redundant and unneeded. And again, specifying a first index > 1 for a row vector, or a second index more than 1 for a column vector will throw an error.
2 Comments
More Answers (1)
KSSV
on 4 Sep 2017
That means y is a cell array and you are extracting 1,3 element out of it. If you want to know it's class type class(y) and if you want it's size type size(y)
3 Comments
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!