필터 지우기
필터 지우기

Type of error - Subscripted assignment dimension mismatch?

조회 수: 4 (최근 30일)
Sarah  Coleman
Sarah Coleman 2012년 4월 20일
In my main function,outside my for loop in which the calculations are done, I created an array:
driTable = zeros(length(A),2);
where length(A) = 5
I have a function with 2 outputs which have been formatted to 1dp within the function, and has been called in the main function:
[driInput1, driInput2] = dri_calculate( z,z2,beta,g);
This how the outputs have been calculated
driInput1 = sprintf('%4.1f',driInput);
driInput2 = sprintf('%4.1f',driInput);
driInput is calculated from:
driInput = ((beta^2)/g)*(max(z));
Once I've returned these outputs to the main function, I do this:
driTable(k,1) = driInput1;
driTable(k,2) = driInput2;
where "k" is the counter of a for-loop. At:
driTable(k,1) = driInput1;
is where I get my error message. The thing is before I did sprintf and just outputted driInput, I didn't get an error message.

채택된 답변

RNTL
RNTL 2012년 4월 20일
I think your variables driInput1/driInput2 are strings and not numeric. check it. if so, unless they of size one (and they are not) you will not be able to assign each of them inside single element of driTable.
  댓글 수: 3
RNTL
RNTL 2012년 4월 20일
>> whos driInput1
and you get that its Type is char.
you need to assign it as numeric type
Sarah  Coleman
Sarah Coleman 2012년 4월 20일
I appreciate your help Ron, it worked.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by