How to make a heat map using three variables?

19 ビュー (過去 30 日間)
Danny Helwegen
Danny Helwegen 2020 年 10 月 13 日
コメント済み: Danny Helwegen 2020 年 10 月 14 日
Hey,
I have an equation calculating the concentration depending on 2 variables (r and theta). I want to make a plot of r vs. theta that shows the concentration at certain points (e.g. for the axis x => r, y=> theta, z => concentration).
I used the following code to calculate the values and generate a matrix A containing the concentration at different r and theta values.
c_1 = 0.5;
R = 10^(-3);
N = 100;
theta = linspace(0,pi/2,N);
r = linspace(0,R,N);
for i = 1:1:N
for j = 1:1:N
A(i,j) = c_1 .* (r(i)./R) .* cos(theta(j));
end
end
The matrix A has (of course) the dimensions N x N. But I don't really know how to make a nice plot for this. Can anyone help me?
Kind regards,
Danny

採用された回答

KSSV
KSSV 2020 年 10 月 13 日
編集済み: KSSV 2020 年 10 月 14 日
c_1 = 0.5;
R = 10^(-3);
N = 100;
theta = linspace(0,pi/2,N);
r = linspace(0,R,N);
[r,theta] = meshgrid(r,theta) ;
A = c_1*(r/R).*cos(theta);
pcolor(r,theta,A)
shading interp
colorbar
  3 件のコメント
KSSV
KSSV 2020 年 10 月 14 日
Use colorbar.
Danny Helwegen
Danny Helwegen 2020 年 10 月 14 日
Thanks for your help, it works

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGeometry and Mesh についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by