How to change only one input if needed?

1 visualización (últimos 30 días)
Venkata Rama Krishna Gona
Venkata Rama Krishna Gona el 22 de Oct. de 2020
Comentada: Andy el 22 de Oct. de 2020
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

Respuestas (2)

KSSV
KSSV el 22 de Oct. de 2020
prompt = "Enter number greater than 5 " ;
m = input(prompt) ;
while m > 5
m = input(prompt) ;
end

Andy
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
Venkata Rama Krishna Gona
Venkata Rama Krishna Gona el 22 de Oct. de 2020
My apologies sir, I havnt got your answer since i dont have much knowledge in the MATLAB. my question was the user will serially enters his values in the above mentioned way. if suppose he entered a values for 'm,k,c,f..' and then for 'k' he entered a wrong value now i need a way to correct only 'k' keeping all the other values intact. please help me i really appreaciate it.thanks
Andy
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

Iniciar sesión para comentar.

Categorías

Más información sobre Programming en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by