Unrecognized function or variable

41 vues (au cours des 30 derniers jours)
Joshua Primeaux
Joshua Primeaux le 8 Fév 2021
syms t
x(t) = piecewise (t>=0, sin(3*t), t>=2*pi, sin(3*t)^2, t>3*pi,0);
t1 =0:0.1:3*pi;
x=subs(x,t,t1);
plot(t1,x)
xlabel('Time')
ylabel('x(t)')
disp('Energy of x(t)')
Energy of x(t)
I1 = int(sin(3*t)^2);
I2 = int(sin(3*t)^4);
E = I1(2*pi)-I1(0)+I2(2*pi)-I2(3*pi)
Energy of x(t)
Unrecognized function or variable 'Energy'.
This is my code I'm not sure why it is saying unrecognized function any help would be appreciated thank you.

Réponses (3)

Steven Lord
Steven Lord le 8 Fév 2021
I suspect you copied and pasted what had been typed and/or displayed in the Command Window (including the text that your disp call displayed, namely "Energy of x(t)") into a file in the Editor/Debugger and tried to run it. You'll need to delete or comment out the displayed text in the file in the Editor/Debugger..
  1 commentaire
Joshua Primeaux
Joshua Primeaux le 8 Fév 2021
ok I fixed that now I'm getting
syms t
x(t) = piecewise (t>=0, sin(3*t), t>=2*pi, sin(3*t)^2, t>3*pi,0);
t1 =0:0.1:3*pi;
x=subs(x,t,t1);
plot(t1,x)
xlabel('Time')
ylabel('x(t)')
disp('Energy of x(t)')
I1 = int(sin(3*t)^2);
I2 = int(sin(3*t)^4);
E = I1(2*pi)-I1(0)+I2(2*pi)-I2(3*pi)
Index exceeds the number of array elements (1).
Error in sym/subsref (line 902)
R_tilde = builtin('subsref',L_tilde,Idx);

Connectez-vous pour commenter.


madhan ravi
madhan ravi le 8 Fév 2021
Following Steven’s answer would clear that error but you will have a following error, so change that part of your code to the following:
%Energy of x(t)
I1(t) = int(sin(3*t)^2);
I2(t) = int(sin(3*t)^4);
E = I1(2*pi)-I1(0)+I2(2*pi)-I2(3*pi)
%Energy of x(t)
  1 commentaire
Joshua Primeaux
Joshua Primeaux le 8 Fév 2021
Thank you that worked

Connectez-vous pour commenter.


muhammad satriawan
muhammad satriawan le 8 Juil 2021
p = [ 0.1987 0.2722 0.0153 0.4451 0.466 0.8462 0.2026 0.8381 0.6813 0.8318 0.7095 0.3046 0.1934 0.3028 ;
0.6038 0.1988 0.7468 0.9318 0.4186 0.5252 0.6721 0.0196 0.3795 0.5028 0.4289 0.1897 0.6822 0.5417 ];
net = newc ([0 1 ; 0 1],6);
net.IW {1,1};
net.b {1};
net = train (net,p);
%Mencari pengelompokan vektor
b = sim(net,p);
ac = vec2ind(b);
net = init(net);
net.trainParam.epochs = 500 ; %pelatihan kohonen
net = train(net,p);
Unrecognized function or variable 'newc'.
Error in JKohonen (line 5)
net = newc ([0 1 ; 0 1],6);

Catégories

En savoir plus sur Symbolic Math Toolbox dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by