- What exactly are you trying to plot here?
- Could you please post the first 10-30 lines of the dataset?
- Could you please post the code you've tried so far?
Plot Graph Based Pair of Columns
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Amritpal Kaur
le 19 Avr 2016
Réponse apportée : Arnab Sen
le 25 Avr 2016
Hello,
I have a dataset like this.
+---------+---------+------------+------------+
| string1 | string2 | col3 | col4 |
+---------+---------+------------+------------+
| abc | xyz | random_num | random_num |
+---------+---------+------------+------------+
| abc | mno | random_num | random_num |
+---------+---------+------------+------------+
| abc | xyz | random_num | random_num |
+---------+---------+------------+------------+
So I have to plot col3 vs. col4 where the pair string1, string2 are repeating, meaning, say for the example above, my plots will be the 1st and 3rd row. string1, string2 can have different but reappearing values. This data set is huge and contains many repeating string1, string2 pairs. How to do that! Thanks.
1 commentaire
Joachim Schlosser
le 19 Avr 2016
Réponse acceptée
Arnab Sen
le 25 Avr 2016
Hi Amritpal,
You may consider the script below for this purpose
toPlot=zeros(size(data(:,1)))
x=[];
y=[];
for i=1:size(data(:,1))
if(toPlot(i)==1)
x(end+1)==data{i,3};
y(end+1)==data{i,4};
continue;
end
col1=data{i,1};
col2=data{i,2};
appearPos=find(strcmp(data(:,1),data(i,1))& strcmp(data(:,2),data(i,2)));
% if size(appearTimes>1)
toPlot(appearPos)=1;
x(end+1)=data{i,3};
y(end+1)=data{i,4};
% end
end
plot(x,y);
Here we are storing the data to plot in x and y array based on the flag set in toPlot array which we set if col1 and col2 combination is repeated.
In my case the 'data' cell array is stored like below format:
>> data
data =
'abc' 'xyz' [4] [3]
'abc1' 'xyz1' [2] [8]
0 commentaires
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!