How to write a for loop to make the column calculations?

1 回表示 (過去 30 日間)
R7 DR
R7 DR 2015 年 7 月 24 日
コメント済み: R7 DR 2015 年 7 月 27 日
Hi,
I have the data of X and Y as shown in the image
I wrote the for loop as shown here, it is making the calculations for the first column. But, how to make the calculations for the rest of the columns in the same for loop?
for i=1:3
y=[Y1{i,1}']
x=[X{i,1}']
A= fminsearch(@(par_fit) funccoats(par_fit,x,y),rand(1,2));
B(i,1)=A(:,1)
C(i,1)=A(:,2)
end
Thanks

採用された回答

James Tursa
James Tursa 2015 年 7 月 24 日
Maybe just add another loop over the columns. E.g.,
for c=1:4
for i=1:3
y=[Y1{i,c}']
x=[X{i,c}']
A= fminsearch(@(par_fit) funccoats(par_fit,x,y),rand(1,2));
B(i,c)=A(:,1)
C(i,c)=A(:,2)
end
end
  1 件のコメント
R7 DR
R7 DR 2015 年 7 月 27 日
Thanks, its working.

サインインしてコメントする。

その他の回答 (1 件)

Muhammad Usman Saleem
Muhammad Usman Saleem 2015 年 7 月 24 日
use another for loop for the calculations over the other columns(Nested for loop).

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by