Looping a function in MATHLAB

1 visualizzazione (ultimi 30 giorni)
Prince Igweze
Prince Igweze il 4 Apr 2020
Risposto: David Hill il 4 Apr 2020
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

Risposte (1)

David Hill
David Hill il 4 Apr 2020
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

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by