フィルターのクリア

Plotting chemical 2d reaction in different colors

1 回表示 (過去 30 日間)
Ulan Kelesbekov
Ulan Kelesbekov 2020 年 4 月 22 日
回答済み: Ayush Gupta 2020 年 6 月 9 日
WIlling to make an image of a 2D reaction of mixing the reagents "A+B=C".
On input have Matrix A and B, velocites, pressures, calculated Stoke's, solved for Pressure and velocities, obtainted moving reagents A B, then calculated C matrix from reaction.
So far came up to this (images 2 and 3, please disregard the first Image):
contourf(x,y,C',20,'k:');
contourf(x,y,A.'+B.',20,'k-');
Question is to how to combine images 2 and 3 with different colours to display output on a single image, i.e. e.g. Red for A, Blue for B and Green for C and white for background.
  2 件のコメント
BALAJI KARTHEEK
BALAJI KARTHEEK 2020 年 4 月 22 日
use hold on command
Ulan Kelesbekov
Ulan Kelesbekov 2020 年 4 月 24 日
編集済み: Ulan Kelesbekov 2020 年 4 月 24 日
does not work for image() and contour() funciton, it overwrites the previous.

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

回答 (2 件)

darova
darova 2020 年 4 月 24 日
What about alpha? Try to set transparency to your object and then just plot them together
[X1,Y1,Z1] = peaks(20);
[X2,Y2] = meshgrid(1:10);
R2 = hypot(X2,Y2);
h1 = surf(X2,Y2,Y2);
h2 = surface(5+X1,5+Y1,Z1/10);
% set([h1 h2],'edgecolor','none')
alpha 0.5
zlim([-1 1])
axis vis3d
for i = 1:100
Z2 = sin(R2+i/10)./R2;
set(h1,'zdata',Z2)
set(h2,'zdata',Z1/10*(50-i)/100)
pause(.1)
end
  2 件のコメント
Ulan Kelesbekov
Ulan Kelesbekov 2020 年 4 月 24 日
alpha seems not to work for countourf, it is suggested to enter manually for flat plot :(
darova
darova 2020 年 4 月 24 日
try to manually change using handles
[x,y,z] = peaks;
z1 = 10*sin(2*hypot(x,y))./hypot(x,y);
[~,h1] = contourf(x,y,z);
hold on
[~,h2] = contourf(x,y,z1);
hold off
h11 = get(h1,'children');
h22 = get(h2,'children');
set(h11,'facealpha',0.5)
set(h22,'facealpha',0.5)

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


Ayush Gupta
Ayush Gupta 2020 年 6 月 9 日
This problem can be tackled using the following approach. Suppose contour1.jpg is the first contour and cntour2.jpg is the second contour, the images can be superimposed using the given piece of code:
figure1 = figure;
ax1 = axes('Parent',figure1);
ax2 = axes('Parent',figure1);
set(ax1,'Visible','off');
set(ax2,'Visible','off');
[a,map] = imread('contour1.jpg');
I = imshow(a,'Parent',ax2);
alpha = 0.5;
set(I,'AlphaData',alpha);
imshow('contour2.jpg','Parent',ax1);

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by