Subscript indices must either be real positive integers or logicals.
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Subscript indices must either be real positive integers or logicals.
Error in ==> Vinci_DLR at 175 alpha_amb = alpha(Nu_amb, la_amb, do, 1);
My alpha-calculation is a very simple function within my m-file and works without error in a single run. For iterative approach I nested it in a while-loop and I got the error above at second iteration. Why? I have similar other functions in this while loop where this problem does not occur.
Examples:
Ra = Raleigh(dT_amb, L, amb_type); % Raleighnr. for ambient convection
Nu_amb = Nusselt(0, Pr_amb, Ra, 0, 0, 2) % Nusselt number
0 Commenti
Risposta accettata
Adam
il 28 Ott 2014
Modificato: Adam
il 28 Ott 2014
I assume alpha is meant to be a function?
Are you also naming a variable alpha within the same workspace? If so then that variable will take precedence and the line you quote will be interpreted as trying to index into the variable rather than pass arguments to the function.
On a similar note, 'alpha' is actually also the name of a builtin Matlab function. It may not be one you require to use within your code, but it is good practice generally to avoid stamping on names of builtin functions unless you actually want to over-ride them.
You can type
which alpha
or
which alpha -all
to find out if a name already exists as function or as a variable too.
0 Commenti
Più risposte (2)
yonatan gerufi
il 28 Ott 2014
your example is very hard to understand.
you should use debug to catch the error.
try this method:
try
your code..
catch
display('error') - put break point here!
end
now, when it stops see the value of indices.
good luck!
Vedere anche
Categorie
Scopri di più su Loops and Conditional Statements in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!