I have a problem replacing certain values within an array that was created by a function with values that were created by another function.
My arrays looks like this:
v = xlsread ("Example");
i = [i_1;i_2;i_3];
n = (v.*60*i_1)/(2*pi*r);
and it creates a 1186x1 vector.
Now I want to recalculate all entries of this vector that are greater than 3000 with a new function that would be
n = (v.*60*i_2)/(2*pi*r);
So far I can only find all coloums with entries greater than 3000 and replace them with a constant value through
j = find (n_M_NEFZ > 3000);
n(n>3000)= 10;
but I cannot replace those values with values from the second function.

 採用された回答

Guillaume
Guillaume 2018 年 8 月 3 日

1 投票

toreplace = n>3000; %find is a waste of time. Use the logical array directly
n(toreplace) = v(toreplace)*60*i_2 / 2*pi*r;
Note that numbered variables (i_1, i_2, i_3) are indication of a bad design. You should index a vector instead (your i that you never use):
n(toreplace) = v(toreplace)*60*i(2) / 2*pi*r;

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMatrices and Arrays についてさらに検索

製品

リリース

R2018a

質問済み:

2018 年 8 月 3 日

回答済み:

2018 年 8 月 3 日

Community Treasure Hunt

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

Start Hunting!

Translated by