how to solve error mentioned in following program?
1 view (last 30 days)
Show older comments
This is my program
[t,Vc]=ode45('capvolt',[0 20e-3],[0])
%capvolt is the function file name
subplot(1,2,1)
plot(t,Vc,'r')
grid
title('Vc')
xlabel('time in sec')
ylabel('voltage Vc')
Vc_analy=10*(1-exp(-10*t))
subplot(1,2,2)
plot(t,Vc_analy)
grid
xlabel('time in sec')
ylabel('voltage Vc_analy')
title('Vc_analy')
%program of the function file capvolt
dVc=100-10*Vc
function dVc=capvolt(t,Vc)
And the error i am facing is : Function definitions are not permitted at the prompt or in scripts.
0 Comments
Answers (1)
Azzi Abdelmalek
on 2 Nov 2013
Edited: Azzi Abdelmalek
on 2 Nov 2013
Your function is not correct. It should be
function dVc=capvolt(t,Vc)
dVc=100-10*Vc
Save this function as capvolt.m, then you can call your function
[t,Vc]=ode45('capvolt',[0 20e-3],[0])
0 Comments
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!