How can i loop I and Ta values from excel sheet from column A(I values) & B(Ta values) for the below mentioned code from row 1 to 10000?
조회 수: 2 (최근 30일)
이전 댓글 표시
I= 1100; % sample irradiance value
Ta = 46.89; % sample temperature value
c=0.0472*I+(1.6586*10^-8)*((Ta+273)^4)+ 4.29*(Ta+273); % equation using I and Ta values which have to be replaced from excel cells
p = [-1.658*10.^-8 0 0 -4.29 c]; % the quartic equation (4th power)
r = roots(p); %finding roots of the quartic equation
out = r(imag(r) == 0 & r > 0) %dispalying the real root value
For example i need the real root to be displayed for A2 and B2 value from the excel which are I and Ta values respectively for each iteration of all those 10000 values. i cant seem to code how to link this looping step. any help is appreciated.
댓글 수: 0
답변 (1개)
Sayam Ganguly
2017년 7월 19일
Hi, I understand that you have an excel file with at least 10000 rows and 2 columns(A for I & B for Ta). Now you are trying to iterate through this excel and use the I & Ta values from each row for your calculation. Here is an approach that you can consider-
data = xlsread('Your file Name','A1:B10000')
for row = data'
I = row(1)
Ta = row(2)
%Code for your calculation goes here
end
Here the code reads the excel file from the specified range of cells(i.e. from A1 to B10000). In each iteration, it stores the "A" value in "I" and the "B" value in "Ta".
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!