Looping a function in MATHLAB

1 回表示 (過去 30 日間)
Prince Igweze
Prince Igweze 2020 年 4 月 4 日
回答済み: David Hill 2020 年 4 月 4 日
Please, how can I loop this function
function y = f(x)
y = sqrt(1 - (x^2)*(Z^2));
end
to solve for different values if Z (ie Z(i))
Thank you

回答 (1 件)

David Hill
David Hill 2020 年 4 月 4 日
No loop needed, just provide Z array to function. Output, y will contain the array of corresponding outputs for the different Z's given the x-value.
function y = f(x,Z)
y = sqrt(1 - (x^2)*(Z.^2));
end

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by