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

Adam
Adam 2015년 11월 26일
편집: Adam 2015년 11월 26일
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 2015년 12월 3일
sorry
my bad
thank you for your answer
yes i want to test if F is not the a member of U

댓글을 달려면 로그인하십시오.

 채택된 답변

Walter Roberson
Walter Roberson 2015년 12월 3일

0 개 추천

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

ali najafi
ali najafi 2015년 12월 4일
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 2015년 12월 4일
thank you it really helped me

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Type Conversion에 대해 자세히 알아보기

질문:

2015년 11월 26일

댓글:

2015년 12월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by