Plotting a contour plot with excel data

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
Sudheer Bhimireddy 2020 年 8 月 12 日

0 投票

doc readmatrix
Import your data into a 2D array and then decide what columns you want to plot using contourf

12 件のコメント

asd ad
asd ad 2020 年 8 月 12 日
I tried it but it didn't work.
Sudheer Bhimireddy
Sudheer Bhimireddy 2020 年 8 月 12 日
Could you paste your code? What is the error you are getting?
asd ad
asd ad 2020 年 8 月 12 日
編集済み: asd ad 2020 年 8 月 12 日
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
Sudheer Bhimireddy
Sudheer Bhimireddy 2020 年 8 月 12 日
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.
asd ad
asd ad 2020 年 8 月 12 日
編集済み: asd ad 2020 年 8 月 12 日
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.
Sudheer Bhimireddy
Sudheer Bhimireddy 2020 年 8 月 12 日
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
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
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
Sudheer Bhimireddy
Sudheer Bhimireddy 2020 年 8 月 13 日
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
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
Sudheer Bhimireddy
Sudheer Bhimireddy 2020 年 8 月 13 日
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
asd ad 2020 年 8 月 13 日
Thank you for your help :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeContour Plots についてさらに検索

質問済み:

2020 年 8 月 12 日

コメント済み:

2020 年 8 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by