A plot command does not work in a newer version of MATLAB

So I'm trying to recreate an old project done by my professor and I'm stuck at this part:
plot(Uprav(:,1), Uprav(:,2));
This piece of code outputs an error "Undefined function or variable 'Uprav'". Even though, I added the variable name in the Logging tab of the Properties of Scope block. The version of MATLAB where the code worked remains unknown. Could you explain to me what is this piece of code supposed to do and suggest me an alternative. Thanks in advance!
Tested versions: R2021a, R2017a

답변 (1개)

Walter Roberson
Walter Roberson 2023년 4월 10일

0 개 추천

The problem is not with plot(): the problem is not finding Uprav .
The line of code you are using can only exist in Simulink inside a MATLAB Function Block; in such a case you would need to have the variable as a signal that is input to the MATLAB Function Block.
I suspect from your discussion of logging, that what is happening is that you have configured the model for the newer single output system, but that it was designed for use with the older output system. I suspect that you have some MATLAB code that is calling sim() and is then assuming that the simulink model wrote the variable into the workspace of the MATLAB code through the output argument process (that is, it does not sound like you are using a To Workspace block).
If I am right then potentially converting back to the older output system would work -- but it would be "better" to stay with the newer single output system and access the data from the unified output; see https://www.mathworks.com/help/simulink/slref/simulink.simulationoutput.html

카테고리

도움말 센터File Exchange에서 Simulink에 대해 자세히 알아보기

제품

릴리스

R2021b

질문:

2023년 4월 10일

답변:

2023년 4월 10일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by