Plotting a contour plot with excel data
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
Hello everyone,
I want to plot a contour plot with the attached excel data. So the colour bar on the right needs to be the RH. The x axis is basially the first column L which is relative to R1......R13. For exaomple 1*R, 2*R. The different initial R should be on the y-axis. How do I best do this?
Thanks in advance
채택된 답변
Sudheer Bhimireddy
2020년 8월 12일
doc readmatrix
Import your data into a 2D array and then decide what columns you want to plot using contourf
댓글 수: 12
asd ad
2020년 8월 12일
I tried it but it didn't work.
Could you paste your code? What is the error you are getting?
contourf(L1,R14,RH1)
k = colorbar;
k.Label.String = 'Relative Humidity (%)';
xlabel('Length (R)')
ylabel('Radius (\mum')
%L1 is the A-column (I removed the R from the xlsx file so the first column just goes from 1-20)
%R14 is the Q-column
%RH1 is the O-colume with the relative humidity
the error I'm getting is that z must atleast be a 2x2 matrix
Look at the sizes of L1, R14 and RH1. In order to draw a contourf you need some gridded data or at the least some data with 2-dimensions.
All of them are 21x1 matrix. How do I fix this problem? Because I have three sets of data and I need RH on the colour bar, the length from 1-20 on the x-axis and the y-axis the R.
Okay, then first you would have to convert them to grid data. (Assuming RH1 is the result at [x,y] points created by L1 and R14)
[L1_xy,R14_xy]=meshgrid(L1,R14); % <- Size of L1_xy, R14_xy would be 21x21
RH1_xy = diag(RH1); % <- size of RH1_xy would be 21x21
contourf(L1_xy,R14_xy,RH1_xy);
asd ad
2020년 8월 12일
The thing is RH1 is independent of R14 and L1. L1 is dependent on R14 for example L1 is from 1 to 20 and each point at L1 is dependent on the intial R14. For example 20*R14 for the first reading gives 5 as the R14 is 0.25. Similarly for every reading it is like that. This is the graph I'm getting now.

asd ad
2020년 8월 12일
Is it possible to get an output like this?
P.S. This is another graph I did with my initial plot code

What is you x- and y-axis? What is the variable which depends on x and y values?
In the second plot you have here, the colormap variable Evaporation Time (s) is available at various Relative Humidity (%) and Volume (mm3) combinations. As a result, it is possible to obtain such plot.
Similarly, if you have RH values defined at various Distance and Droplet Radius combinations, then you could draw a contour map. If RH is completely independent and you want to use it color, see scatter(). Using scatter plot you can draw points at [L1, R14] values and have them colored according to the respective RH values.
asd ad
2020년 8월 13일
Relative Humidity is dependant on the x and y values because the relative humidity is different for each different R but same for the corresponding L. For example for all L which is 1R, RH will be the same. Similarly all values of R at L =2R the relative humidity will be the same
Ah, now I understood your data.
Try this:
data = xlsread('Book2.xlsx');
R = data(1:14,16); % <- Got your R
% Initialize matrices
L = zeros(21,14);
R1 = zeros(21,14);
RH = zeros(21,14);
for i = 1:size(L,1)
L(i,:) = (i-1)*R;
R1(i,:) = R;
RH(i,:) = data(i,14);
end
contourf(L,R1,RH);
c=colorbar;
xlabel('L');ylabel('R');ylabel(c,'RH');

asd ad
2020년 8월 13일
Thank you for your help :)
추가 답변 (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)
