How to change only one input if needed?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (2)
KSSV
am 22 Okt. 2020
prompt = "Enter number greater than 5 " ;
m = input(prompt) ;
while m > 5
m = input(prompt) ;
end
0 Kommentare
Andy
am 22 Okt. 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 Kommentare
Andy
am 22 Okt. 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
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!