Dear members
I have matrix with size M*N and vector with size 1*K
I want to create a null vector with length of N - length of K
I tried this :
V=zeros(1,length(N)-length(K));
but it doesn't work. Any solution please ?
Thank you.

댓글 수: 3

Just Manuel
Just Manuel 2021년 2월 18일
this would be easier if you told us what is not working. Do you get an error message? Or just an unexpected result?
As it stands, your code is valid.
Afluo Raoual
Afluo Raoual 2021년 2월 18일
I get an unexpected result which is:
1*0 empty double row vector
Just Manuel
Just Manuel 2021년 2월 18일
Yep, then go with Bjorn Gustavsson's answer.
Cheers
Manuel

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

 채택된 답변

Bjorn Gustavsson
Bjorn Gustavsson 2021년 2월 18일

0 개 추천

First off if you've done something like:
N = 12;
M = 14;
K = 7;
Mtr = randn(M,N);
V = rand(1,K);
V=zeros(1,length(N)-length(K));
Then you only check the length of the 1-by-1 arrays N and K - and the difference of that is zero. If your N and K are your arrays you might have run into a situation where N < K, because this also happens when N < K. Perhaps you've mixed up the dimensions of your matrix and you meant to make something like this:
V=zeros(1,M - K);
HTH

댓글 수: 4

Afluo Raoual
Afluo Raoual 2021년 2월 18일
No, in my case N > K
I have N=7774 and K=5832
When I put zeros(1,7774-5832) it works, but with zeros(1, length(N)-length(K)) it doesn't work
Yes, then omit the length call. Just do
zeros(1, N-K);
Cheers
Manuel
Afluo Raoual
Afluo Raoual 2021년 2월 18일
It's done. Thank you :)
Just Manuel
Just Manuel 2021년 2월 18일
You're welcome.

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

추가 답변 (0개)

카테고리

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

태그

질문:

2021년 2월 18일

댓글:

2021년 2월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by