how to solve error mentioned in following program?
Afficher commentaires plus anciens
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.
Réponses (1)
Azzi Abdelmalek
le 2 Nov 2013
Modifié(e) : Azzi Abdelmalek
le 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])
Catégories
En savoir plus sur MATLAB Coder dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!