Azzera filtri
Azzera filtri

how to plot separately ..plots getting replaced?

1 visualizzazione (ultimi 30 giorni)
Rakesh Roshan
Rakesh Roshan il 15 Giu 2022
Commentato: Walter Roberson il 16 Giu 2022
for each no of person i should 6 plots properly numbered but i am not getting ..plz correct the error
T=readtable('88.xlsx');
T1=table2cell(T);
n=1;
for i=1:size(T,1)
name=[T{i,1}]
age=T1{i,2};
BP=T1{i,3};
res1=0;
for res=[0 1]
Tobegin(res,name,age,BP,res1,n)
n=n+1;
end
res1=1;
for res=[0 1]
for j=[25]
Tobegin(res,name,age,BP,res1,n)
end
n=n+1;
end
end
function Tobegin(res,name,age,BP,res1,n)
f=[8 9 10 11 12];
s1=[1 2 5 2 3];
figureplots1(f,s1)
s2=[2 4 8 9 10];
figureplots2(f,s2)
s3=[s1+s2];
figureplots3(f,s3)
rowsofdata1=[age BP res res1];
rowsofdata2=[age BP res res1];
dlmwrite('input1.csv',rowsofdata1,'-append','delimiter',',');
dlmwrite('input2.csv',rowsofdata2,'-append','delimiter',',');
end
function figureplots1 (f,s1,n)
plot(f,s1,'-r','LineWidth',3)
ax=gca;ax.YAxis.Exponent=0;grid on
ylabel('S1')
xlabel('freq')
title('dB')
saveas(gca,['Figure',num2str(n),_S1_dB,'.jpg');
plot(f,10*log(s1),'-r','LineWidth',3)
ax=gca;ax.YAxis.Exponent=0;grid on
ylabel('S1')
xlabel('freq')
title('Magnitude')
saveas(gca,['Figure',num2str(n),_S1_abs,'.jpg');
end
function figureplots2 (f,s2,n)
plot(f,s2,'-r','LineWidth',3)
ax=gca;ax.YAxis.Exponent=0;grid on
ylabel('S2')
xlabel('freq')
title('dB')
saveas(gca,['Figure',num2str(n),_S2_dB,'.jpg');
plot(f,10*log(s2),'-r','LineWidth',3)
ax=gca;ax.YAxis.Exponent=0;grid on
ylabel('S2')
xlabel('freq')
title('Magnitude')
saveas(gca,['Figure',num2str(n),_S2_abs,'.jpg');
end
function figureplots3 (f,s3,n)
plot(f,s3,'-r','LineWidth',3)
ax=gca;ax.YAxis.Exponent=0;grid on
ylabel('S3')
xlabel('freq')
title('dB')
saveas(gca,['Figure',num2str(n),_S3_dB,'.jpg');
plot(f,10*log(s3),'-r','LineWidth',3)
ax=gca;ax.YAxis.Exponent=0;grid on
ylabel('S3')
xlabel('freq')
title('Magnitude')
saveas(gca,['Figure',num2str(n),_S3_abs,'.jpg');
end
2018 a version

Risposte (1)

Voss
Voss il 15 Giu 2022
Modificato: Voss il 15 Giu 2022
You had some syntax errors in constructing your file names, and a missing argument in your calls to figureplots*.
Check the code below.
T=readtable('88.xlsx');
T1=table2cell(T);
for i=1:size(T,1)
name=[T{i,1}];
age=T1{i,2};
BP=T1{i,3};
f=[8 9 10 11 12];
s1=[1 2 5 2 3];
figureplots1(f,s1,i)
s2=[2 4 8 9 10];
figureplots2(f,s2,i)
s3=[s1+s2];
figureplots3(f,s3,i)
res1=0;
for res=[0 1]
Tobegin(res,age,BP,res1)
end
res1=1;
for res=[0 1]
for j=[25]
Tobegin(res,age,BP,res1)
end
end
end
delete(gcf());
ls *.jpg % Here is a list of your images. Is it as expected now???
Figure1_S1_abs.jpg Figure1_S2_dB.jpg Figure2_S1_abs.jpg Figure2_S2_dB.jpg Figure3_S1_abs.jpg Figure3_S2_dB.jpg Figure4_S1_abs.jpg Figure4_S2_dB.jpg Figure1_S1_dB.jpg Figure1_S3_abs.jpg Figure2_S1_dB.jpg Figure2_S3_abs.jpg Figure3_S1_dB.jpg Figure3_S3_abs.jpg Figure4_S1_dB.jpg Figure4_S3_abs.jpg Figure1_S2_abs.jpg Figure1_S3_dB.jpg Figure2_S2_abs.jpg Figure2_S3_dB.jpg Figure3_S2_abs.jpg Figure3_S3_dB.jpg Figure4_S2_abs.jpg Figure4_S3_dB.jpg
function Tobegin(res,age,BP,res1)
rowsofdata1=[age BP res res1];
rowsofdata2=[age BP res res1];
dlmwrite('input1.csv',rowsofdata1,'-append','delimiter',',');
dlmwrite('input2.csv',rowsofdata2,'-append','delimiter',',');
end
function figureplots1 (f,s1,n)
plot(f,s1,'-r','LineWidth',3)
ax=gca;ax.YAxis.Exponent=0;grid on
ylabel('S1')
xlabel('freq')
title('dB')
saveas(gca,['Figure',num2str(n),'_S1_dB','.jpg']);
plot(f,10*log(s1),'-r','LineWidth',3)
ax=gca;ax.YAxis.Exponent=0;grid on
ylabel('S1')
xlabel('freq')
title('Magnitude')
saveas(gca,['Figure',num2str(n),'_S1_abs','.jpg']);
end
function figureplots2 (f,s2,n)
plot(f,s2,'-r','LineWidth',3)
ax=gca;ax.YAxis.Exponent=0;grid on
ylabel('S2')
xlabel('freq')
title('dB')
saveas(gca,['Figure',num2str(n),'_S2_dB','.jpg']);
plot(f,10*log(s2),'-r','LineWidth',3)
ax=gca;ax.YAxis.Exponent=0;grid on
ylabel('S2')
xlabel('freq')
title('Magnitude')
saveas(gca,['Figure',num2str(n),'_S2_abs','.jpg']);
end
function figureplots3 (f,s3,n)
plot(f,s3,'-r','LineWidth',3)
ax=gca;ax.YAxis.Exponent=0;grid on
ylabel('S3')
xlabel('freq')
title('dB')
saveas(gca,['Figure',num2str(n),'_S3_dB','.jpg']);
plot(f,10*log(s3),'-r','LineWidth',3)
ax=gca;ax.YAxis.Exponent=0;grid on
ylabel('S3')
xlabel('freq')
title('Magnitude')
saveas(gca,['Figure',num2str(n),'_S3_abs','.jpg']);
end
  5 Commenti
Voss
Voss il 15 Giu 2022
In the code in my answer, figureplots* are no longer being called from Tobegin; this was the reason for the repeats.
Notice how the files generated by the code in my answer go from Figure1 to Figure4. Please use the code as it is.
riki singh
riki singh il 16 Giu 2022
Sir figure plots i have to include in to begin function ..because data in tobegin function is only generating f S1,S2 data... After each simulation figure nos has to get incremented

Accedi per commentare.

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by