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!