資源簡介
該程序適用于用matlab畫隱式函數(shù)的圖,只需要輸入函數(shù)表達式即可。很方便實用!
代碼片段和文件信息
function?h?=?ezimplot3(varargin)
%?EZIMPLOT3????Easy?to?use?3D?implicit?plotter.
%???EZIMPLOT3(FUN)?plots?the?function?FUN(XYZ)?=?0?(vectorized?or?not)?
%???over?the?default?domain:
%???-2*PI?%???FUN?can?be?a?string?an?anonymous?function?handle?a?.M-file?handle?an
%???inline?function?or?a?symbolic?function?(see?examples?below)
%
%???EZIMPLOT3(FUNDOMAIN)plots?FUN?over?the?specified?DOMAIN?instead?of?the
%???default?domain.?DOMAIN?can?be?vector?[XMINXMAXYMINYMAXZMINZMAX]?or
%???vector?[AB]?(to?plot?over?A?%
%???EZIMPLOT3(..N)?plots?FUN?using?an?N-by-N?grid.?The?default?value?for
%???N?is?60.
%???EZIMPLOT3(..‘color‘)?plots?FUN?with?color?‘color‘.?The?default?value
%???for?‘color‘?is?‘red‘.?‘color‘?must?be?a?valid?Matlab?color?identifier.
%
%???EZIMPLOT3(axes_handle..)?plots?into?the?axes?with?handle?axes_handle
%???instead?of?into?current?axes?(gca).
%
%???H?=?EZIMPLOT3(...)?returns?the?handle?to?the?patch?object?this?function
%???creates.
%
%?Example:?
%?Plot?x^3+exp(y)-cosh(z)=4?between?-5?and?5?for?xy?and?z
%
%???via?a?string:
%?f?=?‘x^3+exp(y)-cosh(z)-4‘
%?ezimplot3(f[-5?5])
%
%???via?a?anonymous?function?handle:
%?f?=?@(xyz)?x^3+exp(y)-cosh(z)-4
%?ezimplot3(f[-5?5])
%
%???via?a?function?.m?file:
%------------------------------%
%?function?out?=?myfun(xyz)
%?out?=?x^3+exp(y)-cosh(z)-4;
%------------------------------%
%?ezimplot3(@myfun[-5?5])???or??ezimplot(‘myfun‘[-5?5])
%
%???via?a?inline?function:
%?f?=?inline(‘x^3+exp(y)-cosh(z)-4‘)
%?ezimplot3(f[-5?5])
%
%???via?a?symbolic?expression:
%?syms?x?y?z
%?f?=?x^3+exp(y)-cosh(z)-4
%?ezimplot3(f[-5?5])?
%
%?Note:?this?function?do?not?use?the?“ezgraph3“?standard?like?ezsurf
%?ezmesh?etc?does.?Because?of?this?ezimplot3?only?tries?to?imitate?that
%?interface.?A?future?work?must?be?to?modify?“ezgraph3“?to?include?a
%?routine?for?implicit?surfaces?based?on?this?file
%
%???Inspired?by?works?of:???Artur?Jutan???UWO?02-02-98?ajutan@julian.uwo.ca
%???Made?by:????????????Gustavo?Morales???UC??04-12-09?gmorales@uc.edu.ve
%
%%%?Checking?&?Parsing?input?arguments:
if?ishandle(varargin{1})
???cax?=?varargin{1};?%?User?selected?axes?handle?for?graphics
???axes(cax);
???args{:}?=?varargin{2:end};?%ensuring?args?be?a?cell?array
else
???args?=?varargin;
end
[fun?domain?n?color]?=?argcheck(args{:});
%%%?Generating?the?volumetric?domain?data:
xm?=?linspace(domain(1)domain(2)n);
ym?=?linspace(domain(3)domain(4)n);
zm?=?linspace(domain(5)domain(6)n);
[xyz]?=?meshgrid(xmymzm);
%%%?Formatting?“fun“
[f_handle?f_text]?=?fix_fun(fun);?%?f_handle?is?the?anonymous?f-handle?for?“fun“
??????????????????????????????????%?f_text?is?“fun“?ready?to?be?a?title
%%%?Evaluating?“f_handle“?in?domain:
try
??fvalues?=?f_handle(xyz);????????%?fvalues:?volume?data
catch?ME
??error(‘Ezimplot3:Functions‘?‘FUN?must?have?no?more?than?3?arguments‘);
end
%%%?Making?the?3D?graph?of?the?0-level?surface?of?the?4D?function?“f
評論
共有 條評論