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

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
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
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
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!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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)
