Selecting specific columns in a for loop

10 ビュー (過去 30 日間)
Lui
Lui 2020 年 7 月 11 日
編集済み: madhan ravi 2020 年 7 月 11 日
Hi everyone,
I would like to select to multiply integers between 401:500 with a matrix as shown in the code below
for j=401:500
Meas_Load{j,1}= RLoad2 - j.*RPVR;
end
My expectation is that the variable Meas_Load is a cell if dimension 100 by 1. Unfortunately the resulting dimension is 500 by 1. How can I achieve a 100 by 1 cell in this loop? Thanks
  2 件のコメント
KSSV
KSSV 2020 年 7 月 11 日
What is size of RLoad2, RPVR?
Lui
Lui 2020 年 7 月 11 日
Rload2 has 1000 by 100 and RPVR has 1000 by 1.
Apart from their length, does it matter? All the data sets have the same length. The only difference is in the number of columns.

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

採用された回答

madhan ravi
madhan ravi 2020 年 7 月 11 日
編集済み: madhan ravi 2020 年 7 月 11 日
jj = 401:500;
Meas_Load = cell(numel(jj), 1);
for k = 1:numel(jj)
Meas_Load{k}= Rload2 - jj(k)*RPVR;
end
celldisp(Meas_Load)
Or simply
Meas_Load = Rload2 - reshape(jj, 1, 1, []) .* RPVR; % 3D matrix

その他の回答 (0 件)

カテゴリ

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