t(j) is coming up as an error when trying to graph values. what am i doing wrong
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ennis Winters IV
am 13 Nov. 2019
Bearbeitet: Star Strider
am 13 Nov. 2019
for i= 0:0.1:t1
t(j)=i;
h(j)=v*t(j)*sin(theta)-((g*t(j)*t(j))/2);
x(j)=v*t(j)*cos(theta);
j=(j+i);
end
0 Kommentare
Akzeptierte Antwort
Star Strider
am 13 Nov. 2019
Bearbeitet: Star Strider
am 13 Nov. 2019
It doesn’t appear that you have defined ‘j’ anywhere before the loop.
One possibility:
iv = 0:0.1:t1;
for j = 1:numel(iv)
t(j)=iv(j);
h(j)=v*t(j)*sin(theta)-((g*t(j)*t(j))/2);
x(j)=v*t(j)*cos(theta);
jv(j)=(j+iv(j));
end
2 Kommentare
Star Strider
am 13 Nov. 2019
The problem then is that you are adding ‘i’ to ‘j’. However, the elements of ‘i’ need to be integers, since MATLAB subscript references are defined as integers greater than zero.
I have edited my code creating ‘jv’ so that ‘j’ are only integers.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements 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!