adding zero column to matrix
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hi All,
Currently I'm facing an error with a Matlab code.
In my problem I have Two matrix v and stateHit
v =
0.0044 0.1620 0.0272 0.0029 0.1610 0.6035 0.0151 0.0239
0.0044 0.1639 0.0275 0.0029 0.1606 0.6019 0.0150 0.0238
0.0043 0.1657 0.0279 0.0030 0.1601 0.6002 0.0150 0.0238
stateHit =
1 0 0 0
1 0 0 0
1 0 0 0
I want to do
difMatrix= v(1:length(stateHit),:) - cpustateHit;
??? Error using ==> minus Matrix dimensions must agree.
I want add zero columns to stateHit.
Could please give an example how can add zero columns to stateHit so that matrix dimension of v and stateHit became the same and I do that operations
difMatrix= v(1:length(stateHit),:) - cpustateHit;
many thanks in advance
SM
0 comentarios
Respuesta aceptada
Titus Edelhofer
el 21 de Ag. de 2012
Hi,
if it's just that you want to enlarge "stateHit", you could do
if size(stateHit,2)<size(v, 2)
% v has more columns
stateHit(1, size(v,2)) = 0;
end
Titus
0 comentarios
Más respuestas (1)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!