필터 지우기
필터 지우기

Creating a Traffic Light using matlab code

조회 수: 18 (최근 30일)
Heraldo Tello
Heraldo Tello 2020년 10월 26일
댓글: Varun 2024년 1월 25일
Hello everyone,
I have matlab 2015b. I wrote a code for an assignment that categorizes a dataset as healthy, aged, and replace.
Part of my assignment is to create a horizontal visual dashboard. Basically like a traffic stop light. The traffic light needs to light up green for healthy, yellow for aged, and red for replace based on the point that is being evaluated.
Is this something I would use simulink for or GUI or is it simplier than I think in matlab?
Any help is greatly appreciated.
clear all
close all
clc
load('ThreeClasses')
for i = 1:size(TestPoints,1)
X=TestPoints(i,2);
Y=TestPoints(i,3);
Delta1=log(P1)-0.5*mu1*inv(Sw)*mu1'+mu1*inv(Sw)*[X;Y];
Delta2=log(P2)-0.5*mu2*inv(Sw)*mu2'+mu2*inv(Sw)*[X;Y];
Delta3=log(P3)-0.5*mu3*inv(Sw)*mu3'+mu3*inv(Sw)*[X;Y];
if Delta1 > Delta2 && Delta1 > Delta3
plot(X,Y,'g.','markersize',30);
elseif Delta2 > Delta1 && Delta2 > Delta3
plot(X,Y,'y.','markersize',30);
else
plot(X,Y,'r.','markersize',30);
end
pause(1)
end
  댓글 수: 1
Sudhakar Shinde
Sudhakar Shinde 2020년 10월 27일
Use of GUI to show as red, yellow and green will be more preferable for visual demonstration.

댓글을 달려면 로그인하십시오.

채택된 답변

Nikhil Sonavane
Nikhil Sonavane 2020년 10월 29일
You may use this resource to know more about creating GUI-
  댓글 수: 1
Varun
Varun 2024년 1월 25일
The GUIDE environment will be removed in future releases as stated in below documentation:
Please refer to following documentation for GUIDE Migration Strategies:

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Muhammad Aqib
Muhammad Aqib 2021년 1월 5일
clear all close all clc load('ThreeClasses') for i = 1:size(TestPoints,1) X=TestPoints(i,2); Y=TestPoints(i,3); Delta1=log(P1)-0.5*mu1*inv(Sw)*mu1'+mu1*inv(Sw)*[X;Y]; Delta2=log(P2)-0.5*mu2*inv(Sw)*mu2'+mu2*inv(Sw)*[X;Y]; Delta3=log(P3)-0.5*mu3*inv(Sw)*mu3'+mu3*inv(Sw)*[X;Y]; if Delta1 > Delta2 && Delta1 > Delta3 plot(X,Y,'g.','markersize',30); elseif Delta2 > Delta1 && Delta2 > Delta3 plot(X,Y,'y.','markersize',30); else plot(X,Y,'r.','markersize',30); end pause(1) end

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

제품


릴리스

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by