problem in plot with conditions

1 visualización (últimos 30 días)
huda nawaf
huda nawaf el 29 de Abr. de 2013
hi,
I have table with 2000 rows and 3 columns , each sum(row) either be 1 or 2 or 3
I want to map that as graph. where each row represents user , if sum(row) of uers was 3, then I can know that user is active in online community. I think if got such graph ,it will be important in my work, but if no. of rows is 2000 how the graph will be?
Let c1 is first_column , c2 is seond_column, c3 is third_column
i.e for each row:
if c1=1 , then plot (no_row,1,’*’, ‘color’,’b’)
if c2=1 , then plot (no_row,2,’*’, ‘color’,’b’)
if c3=1 , then plot (no_row,3,’*’, ‘color’,’b’)
if c1=1 and c2=1 then plot (no_row,1,’*’, ‘color’,’g’)
plot (no_row,2,*, color,g)
if c1=1 and c3=1 then plot (no_row,1,’*’, ‘color’,’g’)
plot (no_row,3,*, color,g)
if c1=2 and c3=1 then plot (no_row,1,'*’, ‘color’,’g’)
plot (no_row,3,*, color,g)
if c1=1 and c2=1 and c3=1 then plot (no_row,1,’*’, ‘color’,’r’)
plot (no_row,2,*, color,r)
plot (no_row,3,*, color,r)
thanks in advance
  2 comentarios
Walter Roberson
Walter Roberson el 29 de Abr. de 2013
With your tests arranged like that, if all three columns are 1, then the row would end up getting plotted in 'b', 'g', and 'r'. I don't think that was your intention ?
To check: (0,2,1) and (0,1,2) are also possible? Can any one column contain a 3 ?
huda nawaf
huda nawaf el 29 de Abr. de 2013
Editada: huda nawaf el 29 de Abr. de 2013
sorry ,I forgot to say that is not possible the c1 or c2 or c3 be larger than 1. so each cell at most be have 1 value .
The idea , i want to know who users are active in three periods(three columns), I want to distinguish these people with red color from those who are active in two periods( two columns),and from the others who are active in only one period(one column).
so, those are active in three periods with red color
and who are active n two periods with green color,
and who are active in only one period with blue color.
thanks

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 29 de Abr. de 2013
coltab = [1 1 1; %no activity
0 0 1; %one period
0 1 0; %two periods
1 0 0]; %three periods
logtab = YourTable > 0;
colidx = 1 + sum(logtab, 2);
rowview = repmat([1 2 3], size(logtab,1), 1) .* logtab;
rowview(~rowview) = NaN;
pointsize = 8;
scatter(1:size(rowview,1), rowview .', pointsize, coltab(colidx, :));
  6 comentarios
huda nawaf
huda nawaf el 29 de Abr. de 2013
I said that the entry in each cell impossible be greater than 1 .
it is at most be 1. please go back to my comments
anyway, I have got this error: ??? Error using ==> scatter at 73
X and Y must be vectors of the same length.
error in ==> bar_plot_table_time at 49
scatter(1:size(rowview,1), rowview .', pointsize, coltab(colidx, :));
Walter Roberson
Walter Roberson el 29 de Abr. de 2013
Your sample code had
if c1=2 and c3=1
Anyhow, if you do not need to calculate logtab then you can replace logtab with YourTable in the code that follows.
I understand about the scatter problem; I need to think more about the best way to fix it.

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by