Passing vector argument into a function returns only one value
古いコメントを表示
Hello,
I am trying to create a unit step function without the 0.5 at n = 0, to use within a bigger script. However I cannot input a simple 1D vector into it.
function [a] = ustep(n)
if n<0
a=0;
else
a=1;
end
end
And now this trial code, in which I try to pass -100:100 vector to it, in order to test it. I have useless variables just for testing purposes.
clear; close all; clc;
n = [-100:100];
signal = ustep(n);
signal1 = ustep(0:100);
stem(ustep(n));
stem(n, ustep(n)) straight up doesn't work because ustep() with a vector argument just returns 1. Which is not as sizeable as -100:100 obviously.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で MATLAB Mobile についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!