Saving data from a loop
信息
此问题已关闭。 请重新打开它进行编辑或回答。
显示 更早的评论
Goodday everyone,
I am a newbie in using matlab software and I find it difficult on storing an answer from a loop in a designated variable. I was planning to store the roots of an equation by which the constant variables of the 6th degree polynomial was imported from excel file. I was planning to store the values in columns of the "h" variable. Hope you can help me regarding this matter. The matlab code that i created is shown below.
Thank you very much!
data=xlsread('Soil Characterization.xlsx',5,'C17:K23');
L=length(data(1,:));
x=1;
for xx=1:L+1;
if (xx<L+1);
a = data (1, xx);
b = data (2, xx);
c = data (3, xx);
d = data (4, xx);
e = data (5, xx);
f = data (6, xx);
g = data (7, xx)-10;
y=[a b c d e f g];
w=roots(y);
end
h(x,:)=w;
x=x+1;
end
0 个评论
回答(1 个)
Azzi Abdelmalek
2015-7-8
编辑:Azzi Abdelmalek
2015-7-8
data=xlsread('Soil Characterization.xlsx',5,'C17:K23');
L=length(data(1,:));
h=zeros(L,6)
for xx=1:L;
y=[data(1:6,xx)' data (7, xx)-10 ];
w=roots(y);
h(xx,:)=w';
end
8 个评论
Ezequiel Male
2015-7-8
Azzi Abdelmalek
2015-7-8
Post the error message
Azzi Abdelmalek
2015-7-8
And if possible post a sample of your data
Ezequiel Male
2015-7-8
Jan
2015-7-8
Please post the complete error message.
Ezequiel Male
2015-7-9
编辑:Ezequiel Male
2015-7-9
Azzi Abdelmalek
2015-7-9
you wrote
h(:,xx)=w;
In my code it's
h(xx,:)=w;
Ezequiel Male
2015-7-14
此问题已关闭。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!