Pergunta

I have a matlab file, working fine,

I am trying to conver it using auto coder, however I get an error,

??? Subscripting into an empty matrix is not supported.

ct = 0;
while i <= 1800
        [xx, cc, vv] = doSomething(x, somevalue, Param1, dt);
        %things happening ...
        if something
           flowDt(ct+1) = vv;
           ct = ct + 1;
        end
end

I tried then to declare it before the loop because I got an error: ??? Undefined function or variable 'flowDt'.'

flowDt = [];
ct = 0;
while i <= 1800
        [xx, cc, vv] = doSomething(x, somevalue, Param1, dt);
        %things happening ...
        if something
           flowDt(ct+1) = vv;
           ct = ct + 1;
        end
end

now I am stuck not knowing what is causing this issue: ??? Subscripting into an empty matrix is not supported.

Foi útil?

Solução

Initialize your variable as 0 rather than an empty matrix []

flowDt = [];

then

flowDt = 0; was the solution

so flowDt = 0 will initialize the array, making it not empty

Outras dicas

flow is a Matlab function. That could be the problem. Try changing that variable's name

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top