How can I get the return of a constructed function as an array?
Show older comments
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
>>
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!