programing in Simulink a lamp
i need the lamp to display different color when it gets certain value from the matlab function. i add another Matlab Function to program the lamp but i am not sure if that such a thing to exist.
this is simulink. Here is my code that is in the Matlab Function to program the lamp as you see how i connect the lamp to the function. the code below is the code inside the matlab function. i am not even sure if my code is right at all.
function lampStates = caution(distance)
lampState1.Value = ( distance >= 0.0) && ( distance <= 0.5);
lampState2.Value = ( distance == 0.5);
lampState3.Value = ( distance == 1.5);
lampState4.Value = ( distance == 2.5);
lampState5.Value = ( distance >= 2.5);
if ( distance >= 0.0) && ( distance <= 0.5)
lampState1.Color = [254 51 10];
elseif ( distance == 0.5)
lampState2.Color = [237 177 32];
elseif ( distance == 1.5)
lampState3.Color = [100 212 19];
elseif ( distance == 2.5)
lampState4.Color = [237 177 32];
elseif ( distance >= 2.5)
lampState5.Color = [254 51 10];
end
lampStates = [lampState1 lampState2 lampState3 lampState4 lampState5];i need the lamp to display different color when it gets certain value from the matlab function. i add another Matlab Function to program the lamp but i am not sure if that such a thing to exist.
this is simulink. Here is my code that is in the Matlab Function to program the lamp as you see how i connect the lamp to the function. the code below is the code inside the matlab function. i am not even sure if my code is right at all.
function lampStates = caution(distance)
lampState1.Value = ( distance >= 0.0) && ( distance <= 0.5);
lampState2.Value = ( distance == 0.5);
lampState3.Value = ( distance == 1.5);
lampState4.Value = ( distance == 2.5);
lampState5.Value = ( distance >= 2.5);
if ( distance >= 0.0) && ( distance <= 0.5)
lampState1.Color = [254 51 10];
elseif ( distance == 0.5)
lampState2.Color = [237 177 32];
elseif ( distance == 1.5)
lampState3.Color = [100 212 19];
elseif ( distance == 2.5)
lampState4.Color = [237 177 32];
elseif ( distance >= 2.5)
lampState5.Color = [254 51 10];
end
lampStates = [lampState1 lampState2 lampState3 lampState4 lampState5]; i need the lamp to display different color when it gets certain value from the matlab function. i add another Matlab Function to program the lamp but i am not sure if that such a thing to exist.
this is simulink. Here is my code that is in the Matlab Function to program the lamp as you see how i connect the lamp to the function. the code below is the code inside the matlab function. i am not even sure if my code is right at all.
function lampStates = caution(distance)
lampState1.Value = ( distance >= 0.0) && ( distance <= 0.5);
lampState2.Value = ( distance == 0.5);
lampState3.Value = ( distance == 1.5);
lampState4.Value = ( distance == 2.5);
lampState5.Value = ( distance >= 2.5);
if ( distance >= 0.0) && ( distance <= 0.5)
lampState1.Color = [254 51 10];
elseif ( distance == 0.5)
lampState2.Color = [237 177 32];
elseif ( distance == 1.5)
lampState3.Color = [100 212 19];
elseif ( distance == 2.5)
lampState4.Color = [237 177 32];
elseif ( distance >= 2.5)
lampState5.Color = [254 51 10];
end
lampStates = [lampState1 lampState2 lampState3 lampState4 lampState5]; display different color lamp MATLAB Answers — New Questions