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!