필터 지우기
필터 지우기

MuPad and Symbolic Toolbox Error

조회 수: 1 (최근 30일)
Taniadi
Taniadi 2012년 5월 20일
Hi, i want to ask a question about MuPad. I am beginner using MuPad,
I am trying to solve a coupled of ODE as follow using MuPad syntax:
eq := ode::solve({CA'(t)=-k1*CA(t)+k2*CB(t),CB'(t)=k1*CA(t)-k2*CB(t),CA(0)=3,CB(0)=0},{CA(t),CB(t)})
num := subs(eq,k1=0.5,k2=0.3)
So i get the answer as CA and CB.
But I am actually want to plot CA and CB as function of time. I am using plot command:
plot(num[1],t=0..10)
Error: unbound identifier(s) 'CB, CA' found [plot::Inequality::new]
and plotfunc2d function like this:
plotfunc2d(num[1],t=0..10)
Error: expecting an arithmetical expression or a function, got a 'DOM_LIST' for attribute 'Function' in Function2d object [plot]
I can't get the plot I want, and how can I get this? Do I have to type the solution obtained by solve command manually and use plotfunction2d or plot command?
And finally, I want to export these solution into MATLAB by using mupad command , getVar command, and matlabFunction command, but it yields errors. How can I do this?
Thank you very much

답변 (1개)

Walter Roberson
Walter Roberson 2012년 5월 20일
I think it might be,
ca := subs(CA, num[1]);
cb := subs(CB, num[1]);
plot([ca, cb], t=0..10);
However, this will depend on whether "num" is a single list or is a list of lists. The error message you get for plotfunc2d() would be consistent with "num" being a list of lists, which is what I coded for above.
  댓글 수: 2
Taniadi
Taniadi 2012년 5월 21일
Thanks. I tried the code you suggested to use, and I get this error:
[code]
Error: Illegal argument [subs]
[/code]
Is there error on the code? thanks
Taniadi
Taniadi 2012년 5월 21일
I have found the solution to this problem. Thanks :)

댓글을 달려면 로그인하십시오.

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by