How do i code this variable in Matlab
이전 댓글 표시
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?
답변 (1개)
Walter Roberson
2018년 4월 17일
You can initialize with
W = zeros(size(DF));
or with
W = 0 * DF;
댓글 수: 9
sharifah shuthairah syed abdullah
2018년 4월 17일
Walter Roberson
2018년 4월 17일
No, but you can code
W = zeros(pr_size, size(DF,2))
sharifah shuthairah syed abdullah
2018년 4월 17일
sharifah shuthairah syed abdullah
2018년 4월 17일
편집: sharifah shuthairah syed abdullah
2018년 4월 17일
Walter Roberson
2018년 4월 17일
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
2018년 4월 17일
편집: Walter Roberson
2018년 4월 17일
Walter Roberson
2018년 4월 17일
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
2018년 4월 17일
Walter Roberson
2018년 4월 17일
DF + W
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!