フィルターのクリア

Using the find function

1 回表示 (過去 30 日間)
Denikka Brent
Denikka Brent 2018 年 11 月 11 日
コメント済み: madhan ravi 2018 年 11 月 11 日
I am trying to pull out a certain value in this function. I am trying to find the values of the wbar(i,1),wbar(i,2), and wbar(i,3) each at M=0,0.5,1,and 5. I can get it to work at M=0 and M=5 but not between. Can anyone help with this?
Here is my code:
n = 100;
M = linspace(0,5,n);
wbar = NaN(n,3);
wbar(1,:) = [pi/2,3*pi/2,5*pi/2];
for i=2:n
fun = @(w) cos(w) - M(i)*sin(w);
wbar(i,1) = fzero(fun,wbar(i-1,1));
wbar(i,2) = fzero(fun,wbar(i-1,2));
wbar(i,3) = fzero(fun,wbar(i-1,3));
end
figure(1)
plot(M,wbar,'-')
grid on
index = find(M==2);
freq1=wbar(index,1)
index = find(M==2);
freq2=wbar(index,2)
index = find(M==2);
freq3=wbar(index,3)
  1 件のコメント
Denikka Brent
Denikka Brent 2018 年 11 月 11 日
編集済み: Denikka Brent 2018 年 11 月 11 日
Note: I have M==2 just to see if it will work for any values between 0 and 5

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

採用された回答

madhan ravi
madhan ravi 2018 年 11 月 11 日
編集済み: madhan ravi 2018 年 11 月 11 日
index = (M>2&M<5); %M greater than 2 and less than 5
Logical indexing is efficient
  2 件のコメント
Denikka Brent
Denikka Brent 2018 年 11 月 11 日
Thanks!
madhan ravi
madhan ravi 2018 年 11 月 11 日
Anytime :)

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by