Add Rows to Matrix
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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
0 Kommentare
Antworten (1)
KALYAN ACHARJYA
am 7 Aug. 2019
Bearbeitet: KALYAN ACHARJYA
am 7 Aug. 2019
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 Kommentare
KALYAN ACHARJYA
am 7 Aug. 2019
Bearbeitet: KALYAN ACHARJYA
am 7 Aug. 2019
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);
Siehe auch
Kategorien
Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!