How to output text to Command Window if signal changes from 0 to 1 in Simulink
I want to output text to the command line in Simulink when a signal turns from 0 to 1.
For example, in my model, signal A is zero unless a condition is exceeded in the model, to where signal A is then turned to one. At that point, I want to write "Signal A is 1. Data is invalid" to the command window. I’m currently trying to use a MATLAB function block:
function a = fcn (u)
if u == 1
disp(‘Signal A is 1. Data is invalid’)
a = 1;
else
end
This doesn’t seem to work. any suggestions?I want to output text to the command line in Simulink when a signal turns from 0 to 1.
For example, in my model, signal A is zero unless a condition is exceeded in the model, to where signal A is then turned to one. At that point, I want to write "Signal A is 1. Data is invalid" to the command window. I’m currently trying to use a MATLAB function block:
function a = fcn (u)
if u == 1
disp(‘Signal A is 1. Data is invalid’)
a = 1;
else
end
This doesn’t seem to work. any suggestions? I want to output text to the command line in Simulink when a signal turns from 0 to 1.
For example, in my model, signal A is zero unless a condition is exceeded in the model, to where signal A is then turned to one. At that point, I want to write "Signal A is 1. Data is invalid" to the command window. I’m currently trying to use a MATLAB function block:
function a = fcn (u)
if u == 1
disp(‘Signal A is 1. Data is invalid’)
a = 1;
else
end
This doesn’t seem to work. any suggestions? simulink, if statement, command window MATLAB Answers — New Questions