Borrar filtros
Borrar filtros

Function in a for gives subscript error?

1 visualización (últimos 30 días)
lightworks
lightworks el 15 de Abr. de 2013
Hi,
I have a function that works on it's own just fine, it's something like this:
function [myfunc]=myfunc(X,Y,k)
id=[10100,10046,10453];
file=['./corrcoef' num2str(id(k)) '.mat'];
... calculate some coeficients..
save(file,'coeficients')
end
The script where I call the function later is something like:
id=[10100,10046,10453];
for k=1:size(id,2);
...calculate arrays X and Y..
[myfunc]=myfunc(X,Y,k);
end
This is where I get the error: ??? Subscript indices must either be real positive integers or logicals.
I'm really lost since the function works perfect in the script if I don't call it as a function (copy-paste the code of the function).
What am I doing wrong and how can I fix it?
Thanks in advance!

Respuesta aceptada

Walter Roberson
Walter Roberson el 15 de Abr. de 2013
Do not assign the output of myfunc() to the variable named "myfunc" or else it ceases to be a function reference in that workspace.

Más respuestas (0)

Categorías

Más información sobre Multidimensional Arrays en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by