フィルターのクリア

How do I create a matrix with specific values?

9 ビュー (過去 30 日間)
HelpAStudent
HelpAStudent 2021 年 10 月 1 日
コメント済み: the cyclist 2021 年 10 月 1 日
Hi, I have a matrix (6x21) whose values ​​are those found experimentally. Let's call it: expbasket
I want to calculate the error between the obtained matrix and a matrix having real values.
The real values ​​are in row order: -9; -6; -3; 3; 6; 9 and every columns it's the same.
So I have to have a matrix like this:
realvalue= 6x21
-9 -9 -9 ...
-6 -6 -6 ...
-3 -3 3 ...
3 3 3 ...
6 6 6 ...
9 9 9 ...
By calculating the error, I mean the following operation between matrices:
errorbasket= realvalue - expbasket;
This should be another matrix 6x21;
Next I want to average the values ​​of each column. In order to obtain a vector of 21 elements. Where each element of this vector is the average of the elements of each column of the matrix errorbasket
  1 件のコメント
the cyclist
the cyclist 2021 年 10 月 1 日
FYI, there is a very good tutorial that you might find useful for learning basic operations like these: MATLAB Onramp.

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

採用された回答

DGM
DGM 2021 年 10 月 1 日
編集済み: DGM 2021 年 10 月 1 日
Something like this:
expbasket = randi([-9 9],6,21); % placeholder data
rvalue = [-9; -6; -3; 3; 6; 9]; % don't need the whole matrix
errbasket = mean(rvalue - expbasket,1)
errbasket = 1×21
-1.3333 -1.0000 -1.6667 3.5000 -1.6667 -3.5000 -0.5000 2.3333 -1.3333 1.6667 0.8333 -1.3333 -2.8333 -5.1667 -4.5000 0.3333 2.0000 -1.3333 -2.6667 -1.3333 -0.5000
If you really truly want the reference array to be expanded to 6x21, you can do this instead:
rvalue = repmat([-9; -6; -3; 3; 6; 9],[1 21]);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by