Looping a function in MATHLAB

2 次查看(过去 30 天)
Prince Igweze
Prince Igweze 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 CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by