navg = 11;
filenames = cell(navg,1);
for i = 1:navg
filenames = sprintf('queen2_test_%d.dat', i);
mydata{i} = importdata(filenames);
% writematrix(avg_mat{i}, filenames{i});
R = mydata{i}(:,1);%X
C = mydata{i}(:,2);%Y
F = mydata{i}(:,7);%F(X,Y)
figure
contour(R,C,repmat(F,1,numel(C))');%error line
contourf(R, C, F)% error line
end
Please help me to plot and save high quality contour plots for a sequence of files. I am attaching the code and the data files for your reference.

 채택된 답변

KALYAN ACHARJYA
KALYAN ACHARJYA 2020년 5월 5일

1 개 추천

Create the meshgrid of R,C,F then plot contour

댓글 수: 8

MS
MS 2020년 5월 5일
편집: MS 2020년 5월 5일
Thanks. I have done it already. I got an error.
Error using contourf (line 57)
Z must be at least a 2x2 matrix.
would you mind to add a line?
KALYAN ACHARJYA
KALYAN ACHARJYA 2020년 5월 5일
편집: KALYAN ACHARJYA 2020년 5월 5일
All must be 2D grid R,C,F
MS
MS 2020년 5월 5일
actaully, i do not know it after reading it. Also, i wanted to save the high quality picture automatically. I request to add suitable code if possible.
KALYAN ACHARJYA
KALYAN ACHARJYA 2020년 5월 5일
Is the contour in necessity? Plot3
MS
MS 2020년 5월 5일
편집: MS 2020년 5월 5일
There is a way to plot the contour wthout the meshgrid. I want to plot the high quality contour and save it automatically. Can you help me to add simple correct code to serve my purpose?
KALYAN ACHARJYA
KALYAN ACHARJYA 2020년 5월 5일
편집: KALYAN ACHARJYA 2020년 5월 5일
navg = 11;
filenames = cell(navg,1);
for i = 1:navg
filenames = sprintf('queen2_test_%d.dat', i);
mydata{i}=importdata(filenames);
% writematrix(avg_mat{i}, filenames{i});
R = mydata{i}(:,1);%X
C = mydata{i}(:,2);%Y
F = mydata{i}(:,7);%F(X,Y)
figure
plot3(R,C,repmat(F,1,numel(C))');
grid on;
saveas(gcf,[num2str(i),'.png']);
end
%Example of Saved image
MS
MS 2020년 5월 5일
편집: MS 2020년 5월 5일
Thanks you very much for the help. I need to plot 2D contour plots. Can you take a look at it . Also, i want to save as individual 11 plots. I neea a contour plots as shown in the figure below.
Ameer Hamza
Ameer Hamza 2020년 5월 5일
@MS, the image you posted is a quiver plot, not a contour plot? Which one do you want? Note that for the quiver plot, you will need 4 input variables instead of 3 needed for contour.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Contour Plots에 대해 자세히 알아보기

태그

질문:

MS
2020년 5월 5일

댓글:

2020년 5월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by