Plot different markers on the same graph based on “if-else” statement (third parameter) in AppDesigner
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi,
I have a table of data that I read from Excel using readtable in AppDesigner. The data consists of Lat,Long and Type.
Based on "Type", I would like to plot the Lat (Y) and Long (X) using 2 different markers.
i.e. if Type="A", plot the X & Y coordinates using "+" type marker.
if Type = "B", plot the X & Y coordinates using "square" type marker.
I have try using this kind of coding
.....
.....
.....
t = readtable(Grid.xlsx,opts);
app.UITable.Data = t;
x = app.UITable.Data.Long;
y = app.UITable.Data.Lat;
hold(app.UIAxes,'on')
if strcmp (app.UITable.Data.Type, 'A')
scatter(app.UIAxes,x,y,'+','black');
else
scatter(app.UIAxes,x,y,'square','blue');
end
However, MATLAB plots all the X & Y coordinates using the "+" type marker.
Please advise and thanks in advance
댓글 수: 0
채택된 답변
Cameron
2023년 4월 5일
편집: Cameron
2023년 4월 5일
You should use indexing instead.
t = readtable(Grid.xlsx,opts);
app.UITable.Data = t;
x = app.UITable.Data.Long;
y = app.UITable.Data.Lat;
groupA = string(app.UITable.Data.Type) == "A";
groupB = string(app.UITable.Data.Type) == "B";
hold(app.UIAxes,'on')
scatter(app.UIAxes,x(groupA),y(groupA),'+','black');
scatter(app.UIAxes,x(groupB),y(groupB),'s','blue');
hold(app.UIAxes,'off')
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Bar Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!