How can I get the return of a constructed function as an array?
Mostrar comentarios más antiguos
The constructed function is
function [a] = triangle(n)
a=zeros(size(n));
if (n>=0 & n<=pi) % use an if else statement to execuete
a = pi-n;
else
a = 0; %n; % 0 otherwise
end
end
It can be used with integral function very well. But when I input x = -3:0.01:3, the return velue is 0.
>> x = -3:0.01:3;
>> triangle(x)
ans =
0
>>
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!