- 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
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
Joachim Schlosser
2016-4-19
采纳的回答
Arnab Sen
2016-4-25
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 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!