Plotting column wise data from multiple sheets of Excel spreadsheet into single Scatter plot

Hi, I have one question.Let say I have an excel workbook with 5 separate sheets in it. In each sheet i have column wise data. Now, I want to plot a single scatter plot from all of sheets having two column wise variables let say A and B .
so that i can get one single scatter plot so that i can compare different data sets from each sheet.Also I want to have a single trend line from all data sets so that it can be showed variation of data from trend line and different data sets.
Can anybody give me hint regrading this ??
dataset = xlsread('AllSource_MicArr1.xlsx','Src_1MIC_Array1','A4:T51');
x =dataset(:,10);
y = dataset(:,13);
dataset1 = xlsread('AllSource_MicArr1.xlsx','Src_2MIC_Array1','A4:T51');
a = dataset1(:,10);
b = dataset1(:,13);
dataset2 = xlsread('AllSource_MicArr1.xlsx','Src_3MICArray_1','A4:T51');
c = dataset2(:,10);
d = dataset2(:,13);
dataset3 = xlsread('AllSource_MicArr1.xlsx','Src_4MICArray_1','A4:T51');
e = dataset3(:,10);
f = dataset3(:,13);
scatter(x,y);
hold all
scatter(a,b);
grid on
scatter(c,d);
scatter(e,f);
xlim([-40 80]);
ylim([-40 60]);
xlabel('phi ground');
ylabel('phi sim');
title('Variation between phi ground and phi simulated');
legend('Phi ground and simulated');

6 Commenti

What you have there looks about right for the scatter plots. What seems to be the problem? Are you getting some kind of error?
No, I am not getting any error.
Actually I have huge data sets. These are only few. For huge data sets I have used a loop such as follows:
[~,sheets] = xlsfinfo('C:\Users\Bilal Ahmad\Desktop\Complete Simulations\Microphone Array 1_AllSources\AllSource_MicArr1.xlsx');
for i = 1:length(sheets)
data{i} = xlsread('C:\Users\Bilal Ahmad\Desktop\Complete Simulations\Microphone Array 1_AllSources\AllSource_MicArr1.xlsx',sheets{i},'A4:T51');
x = data{i}(:,10);
y = data{i}(:,13);
scatter(x,y);
end
Actually i want to plot data from all sheets and taking values from column 10 and 13 of each sheet and plot in a single scatter plot but problem is that I have a lot of data that why i have chosen a for loop but when i uses this code it results in only scatter plot from the first sheet.
It looks like you may have forgotten the hold command before the loop. I'm guessing that's why you're only seeing one plot.
Yes, I works now. But still i am facing one problem i want a trend line that passes from all data sets but when i try to create trend line it only gives me a trend line for one data set. Can you help me in this regard.
I think your best way to do this would be to create a separate plot with all points in a single dataset, and then generate a trend line for that new dataset.
That's just my first thought, but I admittedly don't know that much about trend lines in Matlab.

Accedi per commentare.

Risposte (0)

Richiesto:

il 24 Set 2018

Commentato:

il 24 Set 2018

Community Treasure Hunt

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

Start Hunting!

Translated by