Adding legends for a plot in matlab function block.
Afficher commentaires plus anciens
i wanted to add a legend to the plot which is the output from matlab function block, but im ending up with an error as "Function 'legend' not supported for code generation." so can anyone help me out to add this legend function in matlab function block.
function [mean, stdev] = stats(vals)
len = length(vals);
mean = avg(vals,len);
stdev = sqrt(sum(((vals-avg(vals,len)).^2))/len);
plot(vals,"-+");
legend("Autoupdate","off")
end
4 commentaires
Charan
le 19 Jan 2024
Adam Danz
le 22 Jan 2024
Right after receiving this error, could you run the following 2 lines of code and share the content each line produces? Also, please let me now what MATLAB release you're using.
S = lasterror
S.stack
Fangjun Jiang
le 22 Jan 2024
The error is reported by Simulink during model compile. The code has not been able to be executed yet.
Réponses (1)
Fangjun Jiang
le 18 Jan 2024
Modifié(e) : Fangjun Jiang
le 18 Jan 2024
0 votes
There is a way to deal with this type of error.
However, are you sure you want to do this? Because the MATLAB Function block in a Simulink model usually is executed at every simulation step.
This recent Q&A might give you a better idea.
1 commentaire
Charan
le 23 Jan 2024
Déplacé(e) : Fangjun Jiang
le 23 Jan 2024
Catégories
En savoir plus sur Legend dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!