필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Dimension mismatch error in matlab

조회 수: 1 (최근 30일)
Mahi Nazir
Mahi Nazir 2014년 10월 21일
마감: MATLAB Answer Bot 2021년 8월 20일
Hi can someone please explain me why the first one is correct and the second one generates error. I am sure it must be something easy but currently I am unable to get it
for i=1:105
x(i,:)=linspace(0,10,41);
end
>> for i=1:105
x(i,:)=linspace(0,10,48);
end
error:Subscripted assignment dimension mismatch.

답변 (1개)

Michael Haderlein
Michael Haderlein 2014년 10월 21일
In the first loop, you either have not yet initialized x or you have initialized it as n-x-41 array. In any case, after the first loop the size of x will be [105 41]. In the second loop, you want to replace the first line of x (which has 41 entries) by an array of 48 elements. That will fail, obviously. How to solve this problem depends on what you want to do. We need a bit more information for that.

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by