How to loop and calling data from excell
2 次查看(过去 30 天)
显示 更早的评论
i have 100 column vector of data in excell
i need to call the column vector to matlab for iteration and get the value from nonlinier least square
it is so tiring to copy one set of data and do iteration and then copy again the second column data until 100 set for iteration
here is the code look like :
clc clear all close all
global data r p0 w
data = [0.066755733 0.053817978 0.034412989 0.024237233 0.016791611 0.012890878 0.011604633]';
r = [0.8 0.9 1 1.1 1.2 1.3 1.4]';
w = 10;
p0 = rand(2,1);
[p,ssq,cnt] = LMFnlsq2(@resid,ones(2,1),'Display',[-1e4,0],'MaxIter',1e6);
p = p.*p0;
a = p(2)/(3*p(1))
b = p(1)-a
res = resid(p./p0); plot(r,data,'o-', r,res(1:end-1)+data,'-or')
note that the data above is one of column vector data from excell that i copy manually,,
the question is how to make the iteration automatically so after one iteration of data, get and save the value a and b, it will move to next iteration and call next data from excell
so in the end i will get 100 colum vector of a and b
0 个评论
回答(1 个)
Iain
2013-6-6
Roughly you want something like this:
[n t r] = xlsread(filename);
for i = 1:number_of_columns
col = [r{startrow:endrow,i}];
do stuff
a(i) = p(2)/(3*p(1));
b(i) = p(1)-a;
end
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!