Fixing a plot with error message: "Function behaves unexpectedly on array inputs...properly vectorize your function"
Ältere Kommentare anzeigen
I am trying to plot my function "massactcup_frustrumwt" for a range of different values of "t" but every time I try to plot it, though it plots properly, I get an error message: "Function behaves unexpectedly on array inputs. To improve performance, properly vectorize your function to return an output with the same size and shape as the input arguments. "
Can someone please explain to me what this error message means? What does it mean to properly vectorize a function? Also, how should I change my function so that it plots without producing this error message? I want to be able to fix this problem in the future. My function is below:
function [y] = massactcup_frustrumwt (h, rob, rot, t)
rib=rob-t;
rit=rot-t;
A=(rob^2+2*rob*rot+3*rot^2)-(rib^2+2*rib*rit+3*rit^2);
B=(rob^2+rob*rot+rot^2)-(rib^2+rib*rit+rit^2);
COGz=h*A/(4*B);
y=COGz;
end
% Units: everything is in cm. y and y0 are expressed in cm
Thank you,
Jordan
1 Kommentar
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Logical finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!