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