Vectorizing Array -- Wrong Dimensions?
古いコメントを表示
Hi all, I'm a native C programmer and am having a hard time understanding Matlab's behavior.
I have three arrays:
sample.currtargdist (2252 x 1)
sample.targloc (1 x 2552)
distance (6 x 2252)
I can't figure out why this code results in a 2252 x 2252 matrix:
for s = 1:setsize;
distance(s,:) = sqrt((sample.RIGHT_GAZE_X-loc(s).x).^2+(sample.RIGHT_GAZE_Y-loc(s).y).^2);
end
sample.currtargdist = distance(sample.targLoc,:);
When I try something like a '1' instead of ':', I just get the first column of the matrix. I want just the first row of the output matrix.
6 件のコメント
Azzi Abdelmalek
2015 年 7 月 8 日
編集済み: Azzi Abdelmalek
2015 年 7 月 8 日
This is not clear, what is sample.RIGHT_GAZE_X-loc? what is the value of setsize?
Nick G
2015 年 7 月 8 日
Jan
2015 年 7 月 8 日
Which one is "the output matrix"?
Nick G
2015 年 7 月 8 日
Nick G
2015 年 7 月 8 日
採用された回答
その他の回答 (1 件)
Azzi Abdelmalek
2015 年 7 月 8 日
0 投票
Probably, the value of setsize is 2252, or maybe in your code, you have pre-allocated the variable distance with zeros(2252,2252)
カテゴリ
ヘルプ センター および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!