None of the conditions will be met if you pass a vector as you have written the IF tests. IF is true iff (if and only if) all elements of the logical vector that results from the comparison are true--if you pass a vector of arguments that don't all satisfy the same condition, at least one member of that test will be false for every case and so lacking an "else" clause or assignment for that case, the output v is never assigned.
You need something like
function [v] = Deflection_vmndangi(x)
v=zeros(size(x));
ix=(x>0 & x<=120);
v(ix) = (800*x(ix).^3 - 13.68E6*x(ix) - 2.5*x(ix).^4)/3.19E9 ;
ix=(x > 120 & x <= 240);
v(ix) = (800*x(ix).^3 - 13.68E6*x(ix) - 2.5*x(ix).^4 + 25*(x(ix)-120).^4)/3.19E9;
ix=(x>240 & x<=360);
v(ix) = (800*x(ix).^3 - 13.68E6*x(ix) - 2.5*x(ix).^4 + 25*(x(ix)-120).^4 + 600*(x(ix)-240).^3)/3.19E9;
end
so that each element is computed by the given correlation.
See the doc for if and for "logical indexing" for more details.
NB: the "dot" operators are not needed for multiplication by a constant and it's much more efficient to write the coefficient magnitude as a literal constant rather than computing the powers of 10.
Best Answer