How to plot 4D contourf for the matrix C(40*40) with respect to A(40*40) as x axis and B(40*40) as y axis for different levels z=1000, 800, 600, 400 in one plot?
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
Dear Sir I have three matrices A,B and C having same size 40*40. I want to plot a contour of C(40*40) taking A(40*40) as x axis and B(40*40) as y axis for different levels z=1000, 800, 600, 400 in one plot. Please help.
채택된 답변
If your X and Y data are sorted in a good grid, then
contourf(X, Y, C, [400, 600, 800, 1000])
If your X and Y are not sortable to a good grid then you will need to do some grid interpolation and contour that.
댓글 수: 11
Actually I have three matrices X1, Y1, C1 for z=400, X2, Y2, C2 for z=600, X3, Y3, C3 for z=800, X4, Y4, C4 for z=1000 and i want to plot contourf (x, y, c) for each value of z in one plot...please help
contourf(X1, Y1, C1, [400 400]);
hold on
contourf(X2, Y2, C2, [600 600]);
contourf(X3, Y3, C3, [800 800]);
contourf(X4, Y4, C4, [1000 1000]);
hold off
The duplication of the Z value is needed to distinguish from the case of asking for 400 or 600 or 800 or 1000 contour levels to be automatically generated.
I dont know why the above code is not working for me.. Only blank image is coming..but contourf(X1, Y1, C1)is working for indivisual plot without level. Actually i need the plot like this
Thanks a lot for helping me
contour3(X1, Y1, 400*ones(size(X1)), C1, 'filled','on');
hold on
contour3(X2, Y2, 600*ones(size(X2)), C2, 'filled','on');
contour3(X3, Y3, 800*ones(size(X3)), C3, 'filled','on');
contour3(X4, Y4, 1000*ones(size(X4)), C4, 'filled','on');
still the following error is coming
Error using contour3 (line 79)
Invalid LineSpec string.
z is basically atmospheric pressure level....for each pressue level we want to show the contourf plots for three variables...thanks
This is basically four 2d plots presenting in the third direction in a single figure....
Which MATLAB version are you using? The representation of contour plots changed as of R2014b.
Thank you sir for your response... I am using R2013a
This was tricky to figure out.
I have enclosed a file patchfill.m which can be used for this purpose. This is for HG1 (Handle Graphics 1) only in its present form (I do not have an HG2 version to experiment with.) Beware: R2014b and later (HG2) represent contours a different way!
[~, h] = contour3(X1, Y1, C1);
hold on
patchfill(h, 400);
[~, h] = contour3(X2, Y2, C2);
patchfill(h, 600);
[~, h] = contour3(X3, Y3, C3);
patchfill(h, 800);
[~, h] = contour3(X4, Y4, C4);
patchfill(h, 1000);
The patchfill routine I provide does two things:
- alters the patch() properties returned by contour3 to allow the contours to fill. The contours returned by contour3 (in HG1) are deliberately configured to make it hard to turn on filling.
- sets the Z values to the value passed in, if one is passed in.
Thanks a lot :)
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Contour Plots에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
