Loop problem
古いコメントを表示
Hello, I have a loop problem in Matlab
Consider the following datasets:
models = 5x10 (5 rows, 10 columns)
bsdata = 5x20 (5 rows, 20 columns)
I want to do the following calculation:
Result=models(bsdata);
If I do so, I obtain a 5x20 dataset. How can I do this for all the 10 columns of models? I would like to obtain a 10x200 dataset? I have tried the following, but it doesn’t work:
for i=1:10
Result=models(:,i)(bsdata);
end
Thanks,
Pieter
6 件のコメント
Fangjun Jiang
2011 年 5 月 30 日
what do you mean by Result=models(bsdata) since models and bsdata are matrix. What operation do you want to do to obtain the results?
Charles
2011 年 5 月 30 日
Hi,
your question is confusing and maybe you should frame it better.
models = ones(5, 10); %gives a 5 x 10 matrix
bsdata =zeros(5, 20): % 5 x 20 matrix
Result=models(bsdata); %Are not possible, bsdata is larger than models
Result=bsdata(models);%Possible. References bsdata indexed by models.
for i=1:10
Result=models(:,i)(bsdata);
end
This part is not really clear. I think it is better you rather clarify what you mean with words.
Pieter
2011 年 5 月 30 日
Pieter
2011 年 5 月 30 日
Oleg Komarov
2011 年 5 月 30 日
Still not clear why you have a matrix for bsdata instead of a vector. How are you gonna draw a 5 by 20 matrix from a 5 by 30?
Pieter
2011 年 5 月 30 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Measurement-Level Simulations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!