why do I get --- ??? Subscript indices must either be real positive integers or logicals.----- on my code
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
this is my code:
% code
e
clc;
m=1;
c=0;
k=10;
wn=sqrt(k/m);
xi=c/(2*sqrt(k*m));
t0=0;
tf=5;
muestras=1000;
for i=1:muestras+1
t(i)=t0+(i-1)*(tf-t0)/muestras;
if t(i)<=tf
x(i)=1/m((t(i)*cos(t(i)))*(((exp(-wn*t(i)))*(sin(t(i))-wn*cos(t(i)))+wn)/wn^2+1)+t(i)*(sin(t(i)))*(((-exp(-wn*t(i)))*(wn*(sin(t(i)))+(cos(t(i)))/wn^2+1)+(1/(wn^2+1))))-(1/(wn^2+1)^3)*((-exp(-wn*t(i))*-(wn^5)*(t(i)^2)+2*(wn^4)*t(i)^1+2*(wn^3)*(t(i)^2+1)+wn*(t(i)^2-6)-(2*wn^3-6*wn)*(cos(t(i))))));
end
end
plot(t,x,'r')
xlabel('t')
ylabel('x(t)')
grid
hold on
the display shows the next error: ----??? Subscript indices must either be real positive integers or logicals.
Error in ==> EXACTOprueba at 15 x(i)=1/m((t(i)*cos(t(i)))*(((exp(-wn*t(i)))*(sin(t(i))-wn*cos(t(i)))+wn)/wn^2+1)+t(i)*(sin(t(i)))*(((-exp(-wn*t(i)))*(wn*(sin(t(i)))+(cos(t(i)))/wn^2+1)+(1/(wn^2+1))))-(1/(wn^2+1)^3)*((-exp(-wn*t >>
0 Kommentare
Antworten (1)
KSSV
am 31 Okt. 2017
Bearbeitet: KSSV
am 31 Okt. 2017
% code
e
clc;
m=1;
c=0;
k=10;
wn=sqrt(k/m);
xi=c/(2*sqrt(k*m));
t0=0;
tf=5;
muestras=1000;
t = zeros(muestras+1,1) ;
for i=1:muestras+1
t(i)=t0+(i-1)*(tf-t0)/muestras;
if t(i)<=tf
x(i)=1/m*((t(i)*cos(t(i)))*(((exp(-wn*t(i)))*(sin(t(i))-wn*cos(t(i)))+wn)/wn^2+1)+t(i)*(sin(t(i)))*(((-exp(-wn*t(i)))*(wn*(sin(t(i)))+(cos(t(i)))/wn^2+1)+(1/(wn^2+1))))-(1/(wn^2+1)^3)*((-exp(-wn*t(i))*-(wn^5)*(t(i)^2)+2*(wn^4)*t(i)^1+2*(wn^3)*(t(i)^2+1)+wn*(t(i)^2-6)-(2*wn^3-6*wn)*(cos(t(i))))));
end
end
plot(t,x,'r')
xlabel('t')
ylabel('x(t)')
grid
hold on
There is problem in the line NO: 15....you wrote 1/m()..it should be 1/m*()
0 Kommentare
Siehe auch
Kategorien
Mehr zu Shifting and Sorting Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!