How to change only one input if needed?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
clc
close all;
n= input ('enter number of degree of freedoms')
m= input ('enter the values in mass(kg) matrix row wise -')
k= input ('enter the values in stiffness(N/m) matrix row wise-')
c= input ('enter the values in damping matrix -')
f= input ('enter the number of force vectors-')
x0 = input('enter the displacement(m) column matrix row wise-')
x0_dot = input('enter the velocity(m/s) column matrix row wise-')
THESE are my inputs for user if they entered any of value wrong for a variable then i need to restart everything. Please help me how to solve this.Thanks
0 comentarios
Respuestas (2)
KSSV
el 22 de Oct. de 2020
prompt = "Enter number greater than 5 " ;
m = input(prompt) ;
while m > 5
m = input(prompt) ;
end
0 comentarios
Andy
el 22 de Oct. de 2020
I do not know how complex you have to get with the answer but, rather than using input(....) a better way would be to use app designer to create a gui with 7 inputs and a button to start the processing. You can run error checking on the inputs as they are completed ensuring the inputs are the same size and the values will still be in the gui if there is an error you haven't detected.
2 comentarios
Andy
el 22 de Oct. de 2020
Jus tthought that a simpler way than a gui is to use inputdlg but if you have to use input you could try something like this for each data entry
Datacheck = 0;
while Datacheck == 0
n = input ('Enter number of degree of freedom - ');
getreply = input('Are you happy with the data? 1 for Yes, 0 for No');
if getreply == 1
Datacheck = 1;
end
end
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!