Error in a code for (Tunnel diode system)

the first script is
function [xtd] = tunnel_diode_system(t,x)
h=@(z) 17.76*z-103.79*z^2+229.62*z^3-226.31*z^4+83.72*z^5;
xtd= [0.5*(-h(x(1))+x(2)); 0.2*(-x(1)-1.5*x(2)+1.2)];
end
The second script is:
clf;
axis([-.4 1.6 -.4 1.6]);
plot (0.882,0,21,'or',0.063,0,758,'ob');
hold on;
button =1;
options=odeset('AbsTol',1e-8,'RelTol',1e-6);
while button==1;
[xinit(1),xinit(2),button] = ginput(1);
if button ~= 1 break;end;
[t,u]=ode45(@tunnel_diode_system,[0 40],xinit,options);
plot(u(:,1),u(:,2))
[t,u]=ode45(@tunnel_diode_system,[0 40],xinit,options);
plot(u(:,1),u(:,2))
end
I get this error when I run the first script:
Not enough input arguments.
Error in tunnel_diode_system (line 4)
xtd= [0.5*(-h(x(1))+x(2)); 0.2*(-x(1)-1.5*x(2)+1.2)];
and I get this error when I run the second script:
Error using plot
Data must be a single matrix Y or a list of pairs X,Y.
Error in Untitled (line 3)
plot (0.882,0,21,'or',0.063,0,758,'ob');
They are both together, any suggestions?

5 commentaires

Mo'ath Al-Hayek
Mo'ath Al-Hayek le 9 Fév 2021
here are the files
Mo'ath Al-Hayek
Mo'ath Al-Hayek le 9 Fév 2021
here is the code
Walter Roberson
Walter Roberson le 10 Fév 2021
This is not an official support channel; you should not expect Mathworks to reply.
Mo'ath Al-Hayek
Mo'ath Al-Hayek le 10 Fév 2021
Thank you, appreciated

Connectez-vous pour commenter.

Réponses (1)

darova
darova le 10 Fév 2021

0 votes

Here is the mistake
Use dot instead of comma

5 commentaires

Mo'ath Al-Hayek
Mo'ath Al-Hayek le 10 Fév 2021
I edited it, but I got this issue
Walter Roberson
Walter Roberson le 10 Fév 2021
Modifié(e) : Walter Roberson le 10 Fév 2021
[tx, ty, button] = ginput(1);
if isempty(tx) || isempty(button) || button ~= 1
break
end
xinit = [tx(1), ty(1)];
Mo'ath Al-Hayek
Mo'ath Al-Hayek le 10 Fév 2021
Thanks a lot, but substiute it where if you may? I got confused a little bit
clf;
axis([-.4 1.6 -.4 1.6]);
plot (0.882,0,21,'or',0.063,0,758,'ob');
hold on;
options = odeset('AbsTol',1e-8,'RelTol',1e-6);
while true
[tx, ty, button] = ginput(1);
if isempty(tx) || isempty(button) || button ~= 1
break
end
xinit = [tx(1), ty(1)];
[t,u]=ode45(@tunnel_diode_system,[0 40],xinit,options);
plot(u(:,1),u(:,2))
[t,u]=ode45(@tunnel_diode_system,[0 40],xinit,options);
plot(u(:,1),u(:,2))
end
Mo'ath Al-Hayek
Mo'ath Al-Hayek le 10 Fév 2021
Thanks a lot
Much appreciated

Connectez-vous pour commenter.

Catégories

En savoir plus sur Simscape Electrical dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by