フィルターのクリア

Variable change at every time step

4 ビュー (過去 30 日間)
RAKESH KUMAR TOTA
RAKESH KUMAR TOTA 2022 年 1 月 11 日
コメント済み: RAKESH KUMAR TOTA 2022 年 1 月 11 日
for i = 1 :1000
a(:,i) = b ;% assume b size 800 X 1 vector
% but b size changes at random iteration (for loop) depends on the problem i mean it size
% decrease so how to store b values in a as it showing error
end
Error:
Unable to perform assignment because the size of the left side is 1-by-800 and
the size of the right side is 797-by-1.
Other case :
for i = 1 :1000
a(:,i) = b'; % assume b size 800 X 1 vector
% but b size changes at random iteration (for loop) depends on the problem i mean it size
% decrease so how to store b values in a as it showing error
end
Unable to perform assignment because the indices on the left side are not
compatible with the size of the right side.
I can understand what error showing but how to tackle this problem. Any help appreciated .
Thanks in advance.
  4 件のコメント
VBBV
VBBV 2022 年 1 月 11 日
Can you paste the actual error that you faced. Everything in red color text shown at command window
RAKESH KUMAR TOTA
RAKESH KUMAR TOTA 2022 年 1 月 11 日
Unable to perform assignment because the size of the left side is 1-by-800 and the size of the right side is 797-by-1. for first case type
Unable to perform assignment because the indices on the left side are not
compatible with the size of the right side. for second case type

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

採用された回答

KSSV
KSSV 2022 年 1 月 11 日
When you are not sure of size b, you can save them into a cell array.
a = cell(1000,1) ;
for i = 1 :1000
a{i} = b ;
end
You can access any cell using a{1}, a{2},....a{i},...a{1000}.
  5 件のコメント
KSSV
KSSV 2022 年 1 月 11 日
Initializing with dimensions is suggested.
RAKESH KUMAR TOTA
RAKESH KUMAR TOTA 2022 年 1 月 11 日
okay thank you.

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by