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
funtion createzerocolumnvector(x)
x = zeros(56,1)
end
DOES ANYONE KNOW HOW TO DO IT?

답변 (3개)

Bhaskar R
Bhaskar R 2020년 3월 26일

0 개 추천

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

댓글 수: 1

Benjamin Cobb
Benjamin Cobb 2020년 3월 27일
thanks but i need it in a funtion, all good tho found how to do it

댓글을 달려면 로그인하십시오.

Peng Li
Peng Li 2020년 3월 26일

0 개 추천

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);
end
Use y = createZerosColumn(56); to call this function, and y is the result you want.
Venkata Hasini Royal
Venkata Hasini Royal 2022년 10월 22일

0 개 추천

create a 5 by 1 column vectors of zeros

카테고리

도움말 센터File Exchange에서 Programming에 대해 자세히 알아보기

질문:

2020년 3월 26일

답변:

2022년 10월 22일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by