Azzera filtri
Azzera filtri

Type of error - Subscripted assignment dimension mismatch?

4 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

RNTL
RNTL il 20 Apr 2012
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 Commenti
RNTL
RNTL il 20 Apr 2012
>> whos driInput1
and you get that its Type is char.
you need to assign it as numeric type
Sarah  Coleman
Sarah Coleman il 20 Apr 2012
I appreciate your help Ron, it worked.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by