System object tunable parameters
Mostra commenti meno recenti
I have a matlab system object where Truth is a tunable property (it's a struct containing only numeric params) but I'm getting the error below which is causing the Simulink model to recompile each time, what can I do here to keep Truth as tunable and avoid recompiling? Truth will change from run to run so it needs to be tunable.
Warning: The System object 'CreateTruthStruct' specified in the MATLAB System block 'UAV Dynamics/Quadcopter Model/MATLAB System1' has a property 'Truth' defined as tunable. It was set as a non-tunable parameter in the block to work in Simulink. Simulink does not allow parameters whose values are booleans, literal character vectors, string objects or non-numeric structures to be tunable.
classdef CreateTruthStruct < matlab.System
% CreateTruthStruct: This is the system object that will generate the
% TruthStates bus from EOM outputs.
% Public, tunable properties
properties
Truth = struct();
end
end
Risposta accettata
Più risposte (1)
Hi,
The issue you're experiencing with your MATLAB System object is likely due to a mismatch between the class name and the filename. In MATLAB, it's essential that the class name matches the filename exactly. This mismatch can lead to errors and unexpected behavior, such as the warning you're seeing about the ‘Truth’ property causing recompilation in Simulink.
To resolve this issue, please follow these steps:
- Double-check that the filename of your MATLAB System object is the same as the class name. For instance, if your class is defined as‘CreateTruthStruct’, the file should be named‘CreateTruthStruct.m’. This alignment is crucial for MATLAB to correctly recognize and compile the class.
- Ensure that the directory containing your ‘CreateTruthStruct.m’ file is included in the MATLAB path. You can add the directory using the ‘addpath’ function or by going to Home > Set Path in MATLAB. Please refer the documentation for more information: - https://www.mathworks.com/help/releases/R2023b/matlab/ref/addpath.html
Hope this helps to solve the problem. Thanks.
Categorie
Scopri di più su Create System Objects in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!