Effacer les filtres
Effacer les filtres

Type of error - Subscripted assignment dimension mismatch?

4 vues (au cours des 30 derniers jours)
Sarah  Coleman
Sarah Coleman le 20 Avr 2012
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.

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by