Constant Value Output from matlab Function Block in Simulink
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Harsh
am 20 Feb. 2025
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 Kommentare
Siehe auch
Kategorien
Mehr zu Vehicle Network Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!