Variable change at every time step
이전 댓글 표시
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
Geoff Hayes
2022년 1월 11일
@RAKESH KUMAR TOTA - can a be a cell array instead since the b at each iteration can be of different sizes?
RAKESH KUMAR TOTA
2022년 1월 11일
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
2022년 1월 11일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!