create zero column vector
485 ビュー (過去 30 日間)
Benjamin Cobb 2020 年 3 月 26 日
回答済み: Venkata Hasini Royal 2022 年 10 月 22 日
I dont how to create a zero column vector in a function
I thought this was how you did it but i keep getting errors
x = zeros(56,1)
DOES ANYONE KNOW HOW TO DO IT?
回答 (3 件)
Bhaskar R 2020 年 3 月 26 日
zeros is the MATLAB function already, its not recommended to create again a function "createzerocolumnvector(x)", use direct command as
x = zeros(10, 1); % where sencond argument should be 1 so that you get column vector, first argument says number of rows in zeros column vector
For more details read
Peng Li 2020 年 3 月 26 日
x is your input of the function, and within the function body, you overwrite it by assignment. and you don't have any output in this function. after executing, x goes out of scope.
try this if you really want a separate function to do this (although I don't understand why you are so keen on this lol):
function y = createZeroColumn(n)
y = zeros(n, 1);
Use y = createZerosColumn(56); to call this function, and y is the result you want.
Venkata Hasini Royal 2022 年 10 月 22 日
create a 5 by 1 column vectors of zeros
Find more on Programming 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!