Can a for statment contain a matrix
古いコメントを表示
Im trying to filter the data in a matrix, for all values greater then 2.2 I want to know the difference between them and 3.3
This is what have written
for Ns1 >= 2.2
Ns1 = (Ns1-3.3)
end
Ns1 is a 200x1 matrix, I believe this to be the problem, but I haven't been able to find a soloution
Cheers and thankyou.
採用された回答
その他の回答 (1 件)
Walter Roberson
2022 年 4 月 30 日
For vector Ns1:
mask = Ns1 >= 2.2;
Ns1diff = Ns1(mask) - 3.3;
But is that useful? The Ns1diff variable here just contains information for the entries that were >= 2.2, and does not contain any information about where those entries occurred.
Your code (but not your description) hints you might want to subtract 3.3 from each entry that is >= 2.2. If so that is not a problem:
mask = Ns1 >= 2.2;
Ns1(mask) = Ns1(mask) - 3.3;
カテゴリ
ヘルプ センター および File Exchange で Resizing and Reshaping Matrices についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
