Type of error - Subscripted assignment dimension mismatch?

1 次查看(过去 30 天)
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

请先登录,再进行评论。

更多回答(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