Constant Value Output from matlab Function Block in Simulink
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi, I have a matrix Data(2556,4) , where in the first column represent the space traveled of the vehicle that I'm simulating.
I want to compare, during the simulation, the actual distance traveled of the vehicle S and with the column of the Data(:,1). I tought the best way is to use find() function, so once I know the index I could give the output relative to that index. The code is as follow:
function [ax, k, yaw] = Input_Commands(data, x, y)
s = sqrt( (x-0)^2 + (y-0)^2 ); % Creating the distance s from the starting grid
index = find( (s <= data(:,1)), 1);
ax = data(index,2);
k = data(index,3);
yaw = data(index,4);
The problem is that I get the following error: Data 'ax' is inferred as a variable size matrix, while its properties in the Model Explorer specify its size as inherited or fixed. Please check the 'Variable Size' check box and specify the upper bounds in the size field.
I don't know what to do. I tought the problem is the dimension of the output, so I've tried various solutions but with no success.
0 comentarios
Respuestas (1)
Harsh
el 20 de Feb. de 2025 a las 6:21
The “find” function may return an empty array if no elements satisfy the given condition. To resolve this error, go to “Model Explorer” and set the output of your MATLAB function “Input_Commands” as variable size. For more information regarding this, please refer to the following MATLAB answer - https://www.mathworks.com/matlabcentral/answers/392528-variable-size-of-simulink-matlab-function
0 comentarios
Ver también
Categorías
Más información sobre Programmatic Model Editing 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!