Plot different markers on the same graph based on “if-else” statement (third parameter) in AppDesigner
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Cameron
le 5 Avr 2023
Modifié(e) : Cameron
le 5 Avr 2023
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')
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Bar Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!