How do i code this variable in Matlab
Mostrar comentarios más antiguos
i have 2 matrix which have have same size.. if 1st matrix is size 5 the 2nd will also will be 5 if the 1st matrix is size 10 the 2nd will be 10
for example
%1st matrix
DF = [NaN 4 6 ;
3 NaN 5 ;
5 4 NaN ] ;
%2nd matrix
W = [6 10 5 ;
9 7 3 ;
1 4 8 ];
% PROBLEM SIZE (NUMBER OF SITES OR DEPTS)
pr_size = size(DF,1);
how do i code matrix W as pr_size? because W will be follow DF size?
Respuestas (1)
Walter Roberson
el 17 de Abr. de 2018
You can initialize with
W = zeros(size(DF));
or with
W = 0 * DF;
9 comentarios
sharifah shuthairah syed abdullah
el 17 de Abr. de 2018
Walter Roberson
el 17 de Abr. de 2018
No, but you can code
W = zeros(pr_size, size(DF,2))
sharifah shuthairah syed abdullah
el 17 de Abr. de 2018
sharifah shuthairah syed abdullah
el 17 de Abr. de 2018
Editada: sharifah shuthairah syed abdullah
el 17 de Abr. de 2018
Walter Roberson
el 17 de Abr. de 2018
zeros() is allocates an array of the given size, all filled with the value 0.
There is also a function ones() that allocates a matrix of the given size, all filled with the value 1.
You can also use size arguments for nan() and for inf() and for true() and false()
sharifah shuthairah syed abdullah
el 17 de Abr. de 2018
Editada: Walter Roberson
el 17 de Abr. de 2018
Walter Roberson
el 17 de Abr. de 2018
You need to define pr_size before you can use it.
I do not understand what you mean about writing one of them?
Is it possible that you already have D and already have W, and the task is to check to see whether they do have the same size or not?
sharifah shuthairah syed abdullah
el 17 de Abr. de 2018
Walter Roberson
el 17 de Abr. de 2018
DF + W
Categorías
Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!