"Error using input The first argument to INPUT must be a character vector."
Mostra commenti meno recenti
I keep getting error from Matlab when used this code and it refere that the error in "i = input(t);", I attached my code, can anyoone helping me
start_time = 0;
end_time = 10;
dt = 0.005;
times = start_time:dt:end_time;
N = numel(times);
x = [0; 0; 10];
xdot = zeros(3, 1);
theta = zeros(3, 1);
deviation = 100;
thetadot = deg2rad(2 * deviation * rand(3, 1) - deviation);
for t = times
i = input(t);
omega = thetadot2omega(thetadot, theta);
a = acceleration(i, theta, xdot, m, g, k, kd);
omegadot = angular_acceleration(i, omega, I, L, b, k);
omega = omega + dt * omegadot;
thetadot = omega2thetadot(omega, theta);
theta = theta + dt * thetadot;
xdot = xdot + dt * a;
x = x + dt * xdot;
end
4 Commenti
Walter Roberson
il 22 Set 2019
I do not get that error when I test your code. I instead get an error about thetadot2omega not being defined.
for t = times
i = input('t');
It seems odd that you would just prompt with the literal letter 't' for every iteration of a for loop that by concidence has an index variable named t . What is the user supposed to understand from that?
You do not use the variable t anywhere within your loop, so it is not obvious why you are looping over it.
Comments, comments, comments.
muhammad farttoos
il 22 Set 2019
Stephen23
il 22 Set 2019
"can you please check i = input(t); "
There is no point in checking that: as its documentation clearly states, input's first argument must a character vector. The variable t is not a character vector.
Walter Roberson
il 22 Set 2019
i = input( num2str(t) );
But I would have to ask what the user is supposed to understand from being prompted with a time, especially as their input would be ignored ?
Is this all a way to insert a pause that the user has to press return to continue ? If so then just use the pause command
Risposte (0)
Categorie
Scopri di più su MATLAB in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!