contour plot required for this code
조회 수: 2 (최근 30일)
이전 댓글 표시
K = 0.5; M = 0.5; p1 = 0.01; p2 = 0.01; p3 = 0.0; Pr = 2; Ec = 0.05; Q = 0.05; D = 10; b = 0.05; Bi = 0.15;
p2v = linspace(0,0.2,101);Mv = [1 3 5];
for k = 1:numel(Mv)
M = Mv(k);
for i = 1:length(p2v)
p2 = p2v(i);
Cpf = 4179;rhof = 997;kf = 0.613;sgf = 5.5*10^(-5); Cps1 = 765;rhos1 = 3970;ks1 = 40;sis1 = 10^(-10); Cps2 = 5315;rhos2 = 6320;ks2 = 76.5;sis2 = 2.7*10^(-8); Cps3 = 686.2;rhos3 = 4250;ks3 = 8.9538;sis3 = 6.27*10^(-5);H1 = ((1-p1)*(1-p2)*(1-p3))^-2.5; H2 = (1-p3)*( (1-p2)*( 1-p1 + p1*rhos1/rhof ) + p2*rhos2/rhof ) + p3*rhos3/rhof; H3 = (1-p3)*( (1-p2)*(1-p1 + p1*rhos1*Cps1/(rhof*Cpf)) + p2*rhos2*Cps2/(rhof*Cpf) ) + p3*rhos3*Cps3/(rhof*Cpf);C2 = ( (sis1+2*sgf-2*p1*(sgf-sis1))/(sis1+2*sgf+p1*(sgf-sis1))); C3 = ( (sis2+2*C2-2*p2*(C2-sis2))/(sis2+2*C2+p2*(C2-sis2)) );A3 = ( (sis3+2*C3-2*p3*(C3-sis3))/(sis3+2*C3+p3*(C3-sis3)) ); B1 = ( (ks1+2*kf-2*p1*(kf-ks1))/(ks1+2*kf+p1*(kf-ks1)) ); B2 = ( (ks2+2*B1-2*p2*(B1-ks2))/(ks2+2*B1+p2*(B1-ks2)) ); H4 = ( (ks3+2*B2-2*p3*(B2-ks3))/(ks3+2*B2+p3*(B2-ks3)) );
ODE = @(x,y)[y(2); y(3); y(4); M*(x+K).^2*(A3/H1).*(y(2) + (x+K).*y(3)) - 2*y(4)./(x+K) + y(3)./(x+K).^2 - y(2)./(x+K).^3 - (H2/H1)*K*((x+K).^2.*(y(1)*y(4) - y(2)*y(3))) - y(1)*y(2) + (x+K).*(y(1)*y(3)-y(2)^2); y(6); - (Pr/H4)*( Q*(y(5) + exp(-D*x)) + H3*K*y(1)*y(6) + M*Ec*A3*y(2)^2 ) - y(6) ]; BC = @(ya,yb)[ya(1); ya(2)-1-b*(ya(3)-ya(2)/K); ya(6)-Bi*(ya(5)-1); yb([2;3;5])]; xa = 0; xb = 6; x = linspace(xa,xb,101); solinit = bvpinit(x,[0 1 0 1 0 1]); sol = bvp5c(ODE,BC,solinit); S = deval(sol,x);
[X,Y] = meshgrid(p2,S(1,:)); psi(i,:) = X.*Y;
end
end
figure(42),contourf(X,Y,psi,50,'ko','ShowText','on','LineWidth',1.5),hold on;ax = gca; ax.XColor = 'blue'; ax.YColor = 'blue'; ax.XAxis.FontSize = 12; ax.YAxis.FontSize = 12; ax.FontWeight = 'bold';
xlabel('\bfp2','color','blue','FontSize', 14); ylabel('\bf\psi','color','blue','FontSize', 14); % colormap hot
%% I need contourf plot for 'p2' versuses 'psi' for different values of M = [1 3 5];
댓글 수: 0
답변 (1개)
Ishu
2024년 5월 10일
Hi Minati,
When plotting contour plots, the inputs "X" and "Y" must be strictly increasing or decreasing if they are specified as vectors. This requirement does not apply when "X" and "Y" are matrices.
As your "X" and "Y" inputs are vectors and their values are not strictly increasing or decreasing, you should sort these vectors to resolve the error.
XSorted = sort(unique(X));
YSorted = sort(unique(Y));
Another way is you can use "meshgrid" to convert your vectors into matrices.
[X_Matrix, Y_matirx] = meshgrid(X,Y);
참고 항목
카테고리
Help Center 및 File Exchange에서 Contour Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!