Variable Size Data Ouput error
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Abd Al-Rahman Al-Remal
el 24 de Jun. de 2021
Comentada: Abd Al-Rahman Al-Remal
el 24 de Jun. de 2021
I'm simualting a project where one of the matlab functions states the following error:
"'y' is inferred as a variable-size matrix, but its size is specified as inherited or fixed. Verify 'y' is defined in terms of non-tunable parameters, or select the 'Variable Size' check box and specify the upper bounds in the Size box."
I have seen similar posts to this however couldn't find infomation on why my output is variable size,
The code for this aspect of the project is quite small and the following:
function y = sector(Valpha, Vbeta)
sector = [];
%all potential sectors for Vbeta greater than zero
if Vbeta>=0 & abs(Valpha) < abs(Vbeta/sqrt(3));
sector = 2;
end
if Vbeta>=0 & abs(Valpha) > abs(Vbeta/sqrt(3)) & Valpha >= 0;
sector = 1;
else sector = 3;
end
%all potential states for Vbeta less than or equal to zero
if Vbeta < 0 & abs(Valpha) < abs(Vbeta/sqrt(3));
sector = 5;
end
if Vbeta < 0 & abs(Valpha) > abs(Vbeta/sqrt(3)) & Valpha >= 0;
sector = 6;
else sector = 4;
end
y = sector;
Does anyone happen to know why the data is variable size and how I coulf stop it from being such.
Many thanks
2 comentarios
Respuesta aceptada
KSSV
el 24 de Jun. de 2021
Note that the function name and the variable are on the same name. This is not allowed.
7 comentarios
KSSV
el 24 de Jun. de 2021
When you are comapring two vectors....you end up with a vector.
a = rand(10,1) ;
b = rand(10,1) ;
val = zeros(size(a)) ;
%
idx = a > b ;
val(idx) = 1 ;
You can proceed like shown above. So your sector values are going to be vectors.
Más respuestas (0)
Ver también
Categorías
Más información sobre Simulink Coder 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!