Filter löschen
Filter löschen

how to plot two .m files on one graph

1 Ansicht (letzte 30 Tage)
Megan Mirkhanian
Megan Mirkhanian am 31 Jan. 2020
Bearbeitet: KSSV am 31 Jan. 2020
This is one of my files
File2=csvread('secondhalf.CSV')
% samplmean=mean(File2)
% std(File2)
averageY2 = mean(File2);
sigmaY2 = std(File2);
x1 = linspace(min(File2),max(File2),50); %this produces a sorted vector over which to plot the pdf
norm = normpdf(x1,averageY2,sigmaY2);
figure;
plot(x1,norm,'-k');
hold on;
This is the other file
File1=csvread('firsthalf.CSV')
averageY = mean(File1);
sigmaY = std(File1);
x = linspace(min(File1),max(File1),50); %this produces a sorted vector over which to plot the pdf
norm = normpdf(x,averageY,sigmaY);
figure;
plot(x,norm,'-k');
I do not know why my hold on does not work

Akzeptierte Antwort

KSSV
KSSV am 31 Jan. 2020
Bearbeitet: KSSV am 31 Jan. 2020
Remove figure from the second code....as you have used figure, it is opening a new figure.
File2=csvread('secondhalf.CSV')
% samplmean=mean(File2)
% std(File2)
averageY2 = mean(File2);
sigmaY2 = std(File2);
x1 = linspace(min(File2),max(File2),50); %this produces a sorted vector over which to plot the pdf
norm = normpdf(x1,averageY2,sigmaY2);
figure;
plot(x1,norm,'-k');
hold on;
File1=csvread('firsthalf.CSV')
averageY = mean(File1);
sigmaY = std(File1);
x = linspace(min(File1),max(File1),50); %this produces a sorted vector over which to plot the pdf
norm = normpdf(x,averageY,sigmaY);
plot(x,norm,'-k');

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by