Plese help me. Matlab 'while' loop. A set of data is given..?

1 回表示 (過去 30 日間)
J K
J K 2013 年 4 月 27 日
Now I calculate the value of F from equation. From the F that I determined, I need to find the diameter from set of data.
THe method is like this. If my F value is smaller than the value of F from the data, then I choose the corresponding diameter.
For example. The value of F that I calculated is 11. The value of F from the data is 8, 10, 12, 14, 16. The first value is 8, final value is 16, and its corresponding diameter is 1,2,3,4,5.
11 is bigger than 8, the first value of the data, hence we move to the next F on the data. Again, 11 is bigger 10, we move to the next F.
But 11 is less than 12, the iteration is stop. We need not look further. We take the diameter of 12, which is 3.
You get the idea.
And for the set of data. Here's the code. The while (Fa==0) function is the condition that I apply in order to perform this question.
while Fa==0
load data.dat;
diameter=data(:,1);
F=data(:,2);
I'm stuck at that.
Please help me

回答 (1 件)

bym
bym 2013 年 4 月 27 日
編集済み: bym 2013 年 4 月 27 日
x =[ 8, 10, 12, 14, 16]
find(x>=11,1)
ans =
3
edit-----------------------------
x = 8 10 12 14 16
d = 3 5 7 9 10
d(find(x>=11,1))
ans =
7
  3 件のコメント
J K
J K 2013 年 4 月 27 日
This is not what I want.
The 1,2,3,4,5 is the diameter. Not the sequence of the F value.
Let say the diameter of F from the data is 3,5,7,9,10.
How to write the code?
bym
bym 2013 年 4 月 27 日
see edited answer

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by