Hello everyone,
I am a new Matlab user. I have this table bellow:
trackID x y time
0 62.9926 -43.1079 2
2 81.2249 -69.9542 3
0 62.5516 -50.5776 1
3 125.7402 -64.7092 1.5
1 86.2224 -20.5914 2
0 70.1913 -37.885 4
I want to code/say that if the track ID is equal to 1 or 2 or 3 then plot scatter3 (x,y,time)
I am very new to Matlab, I truly appreciate your help or tips.
Thank you!

 Réponse acceptée

rowsToPlot = (t.trackID == 1) || (t.trackID == 2) || (t.trackID == 3)
x = t.x(rowsToPlot);
y = t.y(rowsToPlot);
z = t.time(rowsToPlot);
scatter(x, y, z);
grid on;
xlabel('x');
ylabel('y');
zlabel('time')

4 commentaires

Reem RA
Reem RA le 28 Mai 2022
I am getting this after entering the first line, not sure why:
Unable to resolve the name t.trackID.
>> trackID= xlsread("table1.xlsx", "A:A")
trackID =
0
2
0
3
1
0
>> xx= xlsread("table1.xlsx", "B:B")
xx =
62.9926
81.2249
62.5516
125.7402
86.2224
70.1913
>> yy= xlsread("table1.xlsx", "C:C")
yy =
-43.1079
-69.9542
-50.5776
-64.7092
-20.5914
-37.8850
>> tt= xlsread("table1.xlsx", "D:D")
tt =
2.0000
3.0000
1.0000
1.5000
2.0000
4.0000
>> rowsToPlot = (t.trackID == 1) || (t.trackID == 2) || (t.trackID == 3)
Unable to resolve the name t.trackID.
Perhaps reading it as:
t = readtable("table1.xlsx")
will be in keeping with what @Image Analyst intends.
.
@Rulla RA you said "I have this table bellow:" so I assumed that was true and you had a table variable already. If you don't, just use readtable() like Star said above.
Reem RA
Reem RA le 30 Mai 2022
Thank you so much

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Language Fundamentals dans Centre d'aide et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by