itr=0; % number of iteration
for t=1:1:3
itr=itr+1;
b(itr)=[sin(t) cos(t)];
end
In the above code , I am getting the error " Unable to perform assignment because the indices on the left side are not compatible with the size of the right side."
Please tell me how to fix.

 채택된 답변

Chunru
Chunru 2021년 12월 11일

0 개 추천

itr=0; % number of iteration
for t=1:1:3
itr=itr+1;
b(itr, :)=[sin(t) cos(t)]; % Two numbers for each iteration form a row for a matrix b (nitr x 2)
end
b
b = 3×2
0.8415 0.5403 0.9093 -0.4161 0.1411 -0.9900

댓글 수: 4

SANDIPKUMAR ROYADHIKARI
SANDIPKUMAR ROYADHIKARI 2021년 12월 11일
Thank you
SANDIPKUMAR ROYADHIKARI
SANDIPKUMAR ROYADHIKARI 2021년 12월 12일
itr=0; % number of iteration
for t=1:1:3
itr=itr+1;
b(itr, :)=[sin(t) cos(t)];
c(itr, :)=[1-sin(t) 1];
d(itr,:)=[b;c];
end
I get this error------Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
Please help
itr=0; % number of iteration
for t=1:1:3
itr=itr+1;
b(itr, :)=[sin(t) cos(t)];
c(itr, :)=[1-sin(t) 1];
end
d=[b c]
d = 3×4
0.8415 0.5403 0.1585 1.0000 0.9093 -0.4161 0.0907 1.0000 0.1411 -0.9900 0.8589 1.0000

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

제품

릴리스

R2021b

질문:

2021년 12월 11일

댓글:

2021년 12월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by