Differential Equations and Variables
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello,
I would like to know if it's possible to execute and store results from a simple linear differential equation pulling one of the variable from an external file and storing/saving the results in a different file keeping the same formatting.
To better explain, here is what I am trying to do:
I have a table in excel, column 'I' is one of the variable in my model where values change. I need to compute the results of my differential equation so that the result can be inserted next to each of the cells of 'I'
'I' is the variable which would actually vary in my case
my diff equations is: dx/dt=I(S+A).
Thank you regards J
댓글 수: 0
채택된 답변
Yao Li
2013년 4월 10일
I=xlsread('Path\filename.xlsx','I:I');
%add your own codes to solve the equation
n=length(I);
range=strcat('J1:J',num2str(n));
xlswrite('Path\filename.xlsx',output,range);
댓글 수: 7
Yao Li
2013년 4월 10일
편집: Yao Li
2013년 4월 10일
Assuming I, S and A are stored in columns A,B and C, respectively. The results x will be stored in column D. Hope the codes below can help:
data=xlsread('Path\filename.xlsx','A:C');
I=data(:,1);
S=data(:,2);
A=data(:,3);
time=(30:30:48*60)';
n=length(time);
range=strcat('D1:D',num2str(n));
x0=1;
x(1)=x0;
for i=2:1:n
c(i)=trapz(time(1:i),(I(1:i).*(S(1:i)+A(1:i))));
x(i)=x0*exp(c(i));
end
xlswrite('Path\filename.xlsx',x',range);
Pls. pay attention to the x' in the last row.
Yao Li
2013년 4월 10일
Actually, I think you can also import your data to Simulink to obtain your outputs. If you think it's OK, you can send the Excel file to me by email.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!