Plotting a 3d figure for a function with 4 variables?

5 ビュー (過去 30 日間)
M
M 2021 年 8 月 13 日
コメント済み: DGM 2021 年 8 月 19 日
Hi, I have a function with 4 variables (x,y,z,w) which means d(x,y,z,w)=0, and I have to plot a 3D figure for just 3 variable (x,y,z) without specific values. could you please tell me which matlab function is useful?
here is my code:
function [] = critical()
[x,y,z] = meshgrid(-4:0.1:4,-4:0.1:4,-4:0.1:4);
w=1;
%parameter
a=25;K=0.5;K_p=0.4;K_b=0.3; V_s=0.8;K_s=0.2; gamma=6;K_bar=1.5e-4;
%Function
phi_1 = y.^3 ./ ( y.^3 + K ^3 );
phi_2 = w.^2 ./ ( K_p^2 + w.^2);
phi_3= K_p^2 ./ ( K_p^2 + w.^2);
teta = phi_1 .* phi_2 .* z;
aa = phi_3 .* ( 1 - phi_3).*x;
b = teta./(teta+K_b*(teta+aa));
Beta=(1-K_bar*(gamma*(x-y)./y).^2)./(1+(K_s./y).^2);
alpha=a*b*gamma.*(x-(1+(1/gamma).*y))/V_s;
d=alpha-Beta;
fv=isosurface(x,y,z,d,0)
fv = isosurface(d,0)
fvc = isosurface(d,'blue')
pp = patch(isosurface(x,y,z,d,-0))
isonormals(x,y,z,d,pp)
set(pp,'FaceColor','red','EdgeColor','none');
view(3);
axis tight
camlight
end
when I define w as a vector [w]=meshgrid(-4:0.1:4); it has this error:
Error using .*
Matrix dimensions must agree.
Error in criticalaki (line 11)
teta = phi_1 .* phi_2 .* z;
so I put w=1 which is not true and give me the figure below. but I want a soft figure like surface.
  15 件のコメント
M
M 2021 年 8 月 19 日
Thanks Adam and DGM for your comments,
DGM, I copied your code and run it, it has an error that "out of memory"...
I did something else, solve "alpha-Beta=0" and found an equation that x is written based on y,z,w and use "surface" or "plot3" to plot it.
DGM
DGM 2021 年 8 月 19 日
If you're running out of memory, with that example, then you'd need to reduce the number of points to something less than 400.
If you managed to get it working with surf, then you probably don't need to bother with my example.

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by