How do i code this variable in Matlab

2 ビュー (過去 30 日間)
sharifah shuthairah syed abdullah
sharifah shuthairah syed abdullah 2018 年 4 月 15 日
コメント済み: Walter Roberson 2018 年 4 月 17 日
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
Walter Roberson 2018 年 4 月 17 日

You can initialize with

W = zeros(size(DF));

or with

 W = 0 * DF;
  9 件のコメント
sharifah shuthairah syed abdullah
sharifah shuthairah syed abdullah 2018 年 4 月 17 日
i already have DF and W matrix, they are the same, i want to add matrix DF with W,
Walter Roberson
Walter Roberson 2018 年 4 月 17 日
DF + W

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by