Why this gives error?
이전 댓글 표시
LB=[0 0 0 0];
UB=[10 10 pi pi];
particles_x(1,1)=LB+rand*(UB-LB)
댓글 수: 1
Jan
2022년 4월 15일
I've added the error message. Please care for including the message in future questions about errors.
답변 (2개)
LB = [0 0 0 0];
UB = [10 10 pi pi];
size(LB + rand * (UB - LB))
You cannot assign a [1 x 4] vector to the scalar particles_x(1,1).
KuriGohan
2022년 4월 15일
0 개 추천
You get a 1x4 array on the right that you want to save inside the first row of the first column of the array - you cant do that. Just write particles_x=LB+rand*(UB-LB) and then particles_x(1,1) to acess what you want (at least what i think you want, that is the first element of that matrix).
댓글 수: 5
Sadiq Akbar
2022년 4월 15일
KuriGohan
2022년 4월 15일
Acess just what you want - in your case:
LB=[0 0 0 0];
UB=[10 10 pi pi];
particles_x(1,:)=LB+rand*(UB-LB);
particles_x = particles_x(1,1)
Sadiq Akbar
2022년 4월 15일
Jan
2022년 4월 16일
What are "-ve values" ?
Voss
2022년 4월 16일
I gather "-ve" means "negative" (so the "-" stands for "negati", I guess).
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!