defining a range as a value for while loop

hi everybody I'm trying real hard for finding a way to define a range as a value to put it in a while loop and get a result but I have failed i'm doing it like this:
FX=(5*3.1416*M);
FM=(3*3.1416*M);
F=Wt/(KV*O*M*Y*(10^(-3)));
U=linspace(FM,FX,100);
while F~=U;
do some mathematics;
FX=(5*3.1416*M);
FM=(3*3.1416*M);
U=linspace(FM,FX,100);
F=Wt/(KV*O*M*Y*(10^(-3)));
end
when i insert the values it just says matlab is busy and no result shows up. i don't which part i am doing wrong. i'll be extremely thankful if you give a help

2 comentarios

Adam
Adam el 26 de Nov. de 2015
Editada: Adam el 26 de Nov. de 2015
You haven't really given enough information.
Is F a scalar?
U certainly isn't a scalar so you can't sensibly test:
F ~= U
in a loop. A scalar will never equal a vector and that isn't what you want to test anyway.
Are you trying to test if F is not a member of U or outside of the range it defines or something else?
ali najafi
ali najafi el 3 de Dic. de 2015
sorry
my bad
thank you for your answer
yes i want to test if F is not the a member of U

Iniciar sesión para comentar.

 Respuesta aceptada

Walter Roberson
Walter Roberson el 3 de Dic. de 2015
while ~ismember(F, U)
is the test you asked for in your request "yes i want to test if F is not the a member of U". However, remember that ismember() does equality tests, so if F was even just 2^(-52) different than any member of U then ismember would not find it. I suspect what you want is
while F < FM | F > FX

3 comentarios

ali najafi
ali najafi el 4 de Dic. de 2015
thank you for your answer
i'd much thankful if you answer me another question here, preventing me from making another thread
i want to define a set of numbers like this one:
x = [1,1.25,2,2.5,1.5,3,4,5,6,8,10,12,16,20,25,32,40,50];
and want to choose one of them randomly each time what should i do?
i have used this command for this job:
M=randi(length(x))
but it doesn't choose decimal numbers or sometimes gives me numbers that are not defined in my set of numbers
Use that to give you indices into your array instead of the actual values. Then it will always give you one of your valid values as
x(M)
ali najafi
ali najafi el 4 de Dic. de 2015
thank you it really helped me

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Type Conversion en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 26 de Nov. de 2015

Comentada:

el 4 de Dic. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by