how to plot separately ..plots getting replaced?
조회 수: 1 (최근 30일)
이전 댓글 표시
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
댓글 수: 1
답변 (1개)
Voss
2022년 6월 15일
편집: Voss
2022년 6월 15일
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???
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
Voss
2022년 6월 15일
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
2022년 6월 16일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Data Workflows에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!