I am using vpa function now to 10 sf but it still says it is not numeric, even the lines out of the block says it is a double, I'm really confused
Simulink error, MATLAB expression '<output of NameOfFunction>' is not numeric.
23 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
So I have a function with some symbolic variables so I used coder extrinsic to make a matlab function. The output is an array that is 1 by 3. In the matlab function block I take output of the symbolic function and put it through double but it still gives me this error.
I have tried changing it to a double within the symbolic function, but then it says the expected array 3 by 1 not 1 by 3. So I changed the symbolic output to produce a 3 by 1 array and it just comes up with a much larger grosser error. Anyone know anything that can help.
Respuestas (1)
Imran
el 25 de Nov. de 2022
Hello Katherine,
I understand that you're using 'vpa' function and and not getting the output as a numeric data.
The data type of the output obtained from 'vpa' function is 'sym' which depicts symbolic variable. In order to get double output you need to typecast the output of 'vpa' function to double. For example, take a 3 by 1 array.
x = [1:3]';
p = vpa(x);
% Check the output
disp(class(p)); % = 'sym'
% Typecast it to double
p = double(p);
% Check the data type of the converted output
disp(class(p)); % = 'double'
The above code shows how to get numeric output from 'vpa' function.
I hope this helps.
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!