フィルターのクリア

MAKING A SCATTER PLOT BASED ON INDEX VALUES

16 ビュー (過去 30 日間)
diala yazbeck
diala yazbeck 2021 年 2 月 23 日
編集済み: diala yazbeck 2021 年 2 月 23 日
hello!
so i have a table with 5 columns.
column 1 has values 1-12 (but this can vary depending on the data set), column 2 is time, column 3 is either 1 or 0 (right/left), and column 4 and 5 are x and y co-ordinates respectively.
i need to plot the values in column 4 and 5 based on the index value in column 1.
so if the index value is 88 for 1, i want to plot column 4 and 5 from 1 -88.
if the next index is 98 for 2 , i want to 4 and 5 from 88 - 186
etc
i would also like to set up subplots based on the unique numbers in column 1 (i.e 1-12)
i have no code. i have absolutely no idea how to implement this.
this only script i have is determining the index.

採用された回答

KSSV
KSSV 2021 年 2 月 23 日
編集済み: KSSV 2021 年 2 月 23 日
[C,ia,ib] = unique(column1) ; % column1 is your column
idx = zeros(size(column1)) ; % make indices to save each class
for i = 1:length(C)
idx(ib==i) = i ;
end
gscatter(x,y,idx) % use gscatter (x,y) are your values to be plotted
  3 件のコメント
KSSV
KSSV 2021 年 2 月 23 日
[C,ia,ib] = unique(column1) ; % column1 is your column
for i = 1:length(C)
figure(i)
plot(x(ib==i),y(ib==i)) ;
end
diala yazbeck
diala yazbeck 2021 年 2 月 23 日
編集済み: diala yazbeck 2021 年 2 月 23 日
THANK YOU SO MUCH ! THATS EXACTLY WHAT I WANTED!!!
also,
is there a way to change the colour of the figures based on whether column 3 is a 0 or a 1?
for i = 1:length(C)
figure(i)
gscatter(x(ib==i),y(ib==i), g(ib==i));
title(sprintf('COP %d',i))
end
this is my script so far

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by