Hello! I'm trying to create a matrix with zero values
[x,y]=min(Data); % Data 200x1000 x=1x1000 (double)
a=[10 10 10...] % my calculated values, as a 1x1000 ( single) array
zeromatrix=zeros(a,length(x));
res = bsxfun(@plus, Data, zeromatrix);
Error using zeros
Size inputs must be scalar.
I'm trying to add the number of rows I need to the Data matrix, but it gives me an error, please help me how to solve it
Data Data 200x1000 , and I want to get the matrix Data 210x1000

답변 (1개)

KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 8월 7일
편집: KALYAN ACHARJYA 2019년 8월 7일

0 개 추천

The issue is:
zeromatrix=zeros(a,length(x));
%................^ sizes must be scalar value, you pass the vector a
Is this one, where res 100x100?
[x,y]=min(Data); % Data 200x1000 x=1x100 (double)
a=rand(1,100); % my calculated values, as a 1x1000 ( single) array
zeromatrix=zeros(length(a),length(x));
res=bsxfun(@plus, Data, zeromatrix);
You can do it in simpler ways. If you are looking for different, can you elaboarte with small example

댓글 수: 4

Error using bsxfun
Non-singleton dimensions of the two input arrays must match each other.
gives such an error
I have tried with this sample data, no error, Note on Data and a
Data=randi(200,100);
[x,y]=min(Data); % Data 200x1000 x=1x100 (double)
a=rand(1,100); % my calculated values, as a 1x1000 ( single) array
zeromatrix=zeros(length(a),length(x));
res=bsxfun(@plus, Data, zeromatrix);
[x,y]=min(Data); % Data 200x1000 x=1x1000 (double)
a=[10 10 10...] % my calculated values, as a 1x1000 ( single) array
zeromatrix=zeros(a(1),length(x));
res = bsxfun(@plus, Data, zeromatrix);
Error using bsxfun
Non-singleton dimensions of the two input arrays must match each other.
since a in all columns takes one value, I did so (a = 10x1000) and still shows an error when adding rows to my matrix ps the desired matrix has been created now I need to add it line by line
KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 8월 7일
편집: KALYAN ACHARJYA 2019년 8월 7일
Data=randi(200,1000);
[x,y]=min(Data); % Data 200x1000 x=1x100 (double)
a=rand(1,1000); % my calculated values, as a 1x1000 ( single) array
zeromatrix=zeros(length(a),length(x));
res=bsxfun(@plus, Data, zeromatrix);
1234.png

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

카테고리

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

제품

질문:

2019년 8월 7일

편집:

2019년 8월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by