can someone explain the error in this input for loop
Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
Ältere Kommentare anzeigen
Q0 = [];
for i=1:2
p = input(sprintf('Enter value for p(distance) [%d model]:',i));
v = input(sprintf('Enter value for v(velocity) [%d model]',i));
a = input(sprintf('Enter value for a(acceleration) [%d model]',i));
j = input(sprintf('Enter value for j(jerk)[%d model]',i));
Q0 = [Q0 ; p ; v ; a ; j ];
fprintf(Q0);
end
Enter value for p(distance) [1 model]:1
Enter value for v(velocity) [1 model]2
Enter value for a(acceleration) [1 model]3
Enter value for j(jerk)[1 model]4
Undefined function or variable 'Q0'.
I dont understand why its prompting me undefined variable.
3 Kommentare
Walter Roberson
am 4 Aug. 2019
It looks ok on my screen, but double check your initialization in case you initialized QO instead of Q0
Travis Heckler
am 4 Aug. 2019
Travis Heckler
am 4 Aug. 2019
Antworten (1)
Ajay Pattassery
am 7 Aug. 2019
0 Stimmen
If you can see the issue again, revert with the error message and the code you have used. Also correct the usage of fprintf command in the above code. You need to specify the format of the output field. For example, if you are expecting integers use.
fprintf("%d",Q0);
Diese Frage ist geschlossen.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!