Unrecognized function or variable

조회 수: 32 (최근 30일)
Joshua Primeaux
Joshua Primeaux 2021년 2월 8일
답변: muhammad satriawan 2021년 7월 8일
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.

답변 (3개)

Steven Lord
Steven Lord 2021년 2월 8일
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
Joshua Primeaux
Joshua Primeaux 2021년 2월 8일
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);

댓글을 달려면 로그인하십시오.


madhan ravi
madhan ravi 2021년 2월 8일
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)

muhammad satriawan
muhammad satriawan 2021년 7월 8일
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);

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by