ezplot('sin(t)')
ezplot('sin(t)',[-4*pi 4*pi])
ezplot('sin(t)/t',[-4*pi 4*pi])
ezplot('x^2+y^2-1',[-1 1 -1 1])
hold on
ezplot('x^4+y^4-1',[-1 1 -1 1])
ezplot('x^6+y^6-1',[-1 1 -1 1])
ezplot('x^8+y^8-1',[-1 1 -1 1])
ezplot('x^10+y^10-1',[-1 1 -1 1])
title('"Five Hypercircles')
title('Five Hypercircles')
axis('equal','tight','off')
hold on
hold off
ezplot('t-sin(t)','1-cos(t)',[-.5*pi 2.5*pi])
axis('equal','tight','off')
ezplot3('cos(t)','sin(t)','t/(2*pi)',[0 6*pi])
ezmesh('sin(sqrt(x^2+y^2))/sqrt(x^2+y^2)',[-4*pi 4*pi -4*pi 4*pi])
ezsurf('sin(sqrt(x^2+y^2))/sqrt(x^2+y^2)',[-4*pi 4*pi -4*pi 4*pi])
axis('square')
shading interp
ezcontour('sin(sqrt(x^2+y^2))/sqrt(x^2+y^2)',[-4*pi 4*pi -4*pi 4*pi])
axis('square')
help ezcontour
ezcontour (NOT RECOMMENDED) Easy to use contour plotter
===================================================
ezcontour is not recommended. Use FCONTOUR instead.
===================================================
ezcontour(FUN) plots the contour lines of FUN(X,Y) using CONTOUR. FUN
is plotted over the default domain -2*PI < X < 2*PI, -2*PI < Y < 2*PI.
ezcontour(FUN,DOMAIN) plots FUN over the specified DOMAIN instead of
the default domain. DOMAIN can be the vector [XMIN,XMAX,YMIN,YMAX]
or the vector [A,B] (to plot over A < X < B and A < Y < B).
ezcontour(...,N) plots FUN over the default domain using an N-by-N
grid. The default value for N is 60.
ezcontour(AX,...) plots into AX instead of GCA.
H = ezcontour(...) returns handles to contour objects in H.
Examples:
The easiest way to express a function is via a string:
ezcontour('x*exp(-x^2 - y^2)')
One programming technique is to vectorize the string expression using
the array operators .* (TIMES), ./ (RDIVIDE), .\ (LDIVIDE), .^ (POWER).
This makes the algorithm more efficient since it can perform multiple
function evaluations at once.
ezcontour('x.*exp(-x.^2 - y.^2)')
You may also use a function handle to an existing function. Function
handles are more powerful and efficient than string expressions.
ezcontour(@peaks)
ezcontour plots the variables in string expressions alphabetically.
subplot(1,2,1), ezcontour('x.*exp(-x.^2 - y.^2)')
To avoid this ambiguity, specify the order with an anonymous function:
subplot(1,2,2), ezcontour(@(y,x)x.*exp(-x.^2 - y.^2))
If your function has additional parameters, for example k in myfun:
%-----------------------%
function z = myfun(x,y,k)
z = x.^k - y.^k - 1;
%-----------------------%
then you may use an anonymous function to specify that parameter:
ezcontour(@(x,y)myfun(x,y,2))
See also ezplot, ezplot3, ezpolar, ezcontourf, ezsurf, ezmesh,
ezsurfc, ezmeshc, contour, vectorize, function_handle.
Reference page for ezcontour
Other functions named ezcontour
ezcontour('sin(sqrt(x^2+y^2))/sqrt(x^2+y^2)',[-4*pi 4*pi -4*pi 4*pi],120)
axis('square')
xVals=[1 2 3 5 8 13 22 36 60 100]
xVals =
1 2 3 5 8 13 22 36 60 100
yVals=3*xVals.^1.5
yVals =
1.0e+03 *
Columns 1 through 7
0.0030 0.0085 0.0156 0.0335 0.0679 0.1406 0.3096
Columns 8 through 10
0.6480 1.3943 3.0000
rng('default')yVals=yVals*(1+0.1*randn(size(xVals)))
rng('default')yVals=yVals*(1+0.1*randn(size(xVals)))
{Error: Invalid expression. Check for missing multiplication operator, missing
or unbalanced delimiters, or other syntax error. To construct matrices, use
brackets instead of parentheses.
}
rng('default')
yVals=yVals*(1+0.1*randn(size(xVals)))
{Error using *
Incorrect dimensions for matrix multiplication. Check that the number of
columns in the first matrix matches the number of rows in the second matrix. To
perform elementwise multiplication, use '.*'.}
yVals=yVals.*(1+0.1*randn(size(xVals)))
yVals =
1.0e+03 *
Columns 1 through 7
0.0026 0.0111 0.0167 0.0333 0.0727 0.1377 0.3057
Columns 8 through 10
0.7445 1.5907 3.4252
yVals=3*xVals.^1.5
yVals =
1.0e+03 *
Columns 1 through 7
0.0030 0.0085 0.0156 0.0335 0.0679 0.1406 0.3096
Columns 8 through 10
0.6480 1.3943 3.0000
loglog(xVals,yVals,'o-')
rng('default')
yVals=yVals.*(1+0.1*randn(size(xVals)))
yVals =
1.0e+03 *
Columns 1 through 7
0.0032 0.0100 0.0121 0.0364 0.0700 0.1222 0.2961
Columns 8 through 10
0.6702 1.8932 3.8308
loglog(xVals,yVals,'o-')
Coefs=polyfit(log(xVals),log(yVals),1)
Coefs =
1.5442 1.0428
p=Coefs(1)
p =
1.5442
C=exp(Coefs(2))
C =
2.8372
(C-3)/3
ans =
-0.0543
yPower=C*xVals.^p
yPower =
1.0e+03 *
Columns 1 through 7
0.0028 0.0083 0.0155 0.0341 0.0704 0.1490 0.3357
Columns 8 through 10
0.7181 1.5805 3.4785
loglog(xVals,yVals,'o',xVals,yPower,'-')
yPowerExact=3*xVals.^1.5;
loglog(xVals,yVals,'o',xVals,yPower,'-',xVals,yPowerExact,'--')
xValues=linspace(0,1,n)
{Undefined function or variable 'n'.}
n=5
n =
5
m=4
m =
4
xValues=linspace(0,1,n)
xValues =
0 0.2500 0.5000 0.7500 1.0000
yValues=linspace(0,1,m)
yValues =
0 0.3333 0.6667 1.0000
[xGrid yGrid]=meshgrid(xValues,yValues)
xGrid =
0 0.2500 0.5000 0.7500 1.0000
0 0.2500 0.5000 0.7500 1.0000
0 0.2500 0.5000 0.7500 1.0000
0 0.2500 0.5000 0.7500 1.0000
yGrid =
0 0 0 0 0
0.3333 0.3333 0.3333 0.3333 0.3333
0.6667 0.6667 0.6667 0.6667 0.6667
1.0000 1.0000 1.0000 1.0000 1.0000
plot(xGrid,yGrid,'or')
% must specify an array forcing
forcing=ones(m,n)
forcing =
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
forcing=ones(m,n)*2
forcing =
2 2 2 2 2
2 2 2 2 2
2 2 2 2 2
2 2 2 2 2
forcing(1,:)=1
forcing =
1 1 1 1 1
2 2 2 2 2
2 2 2 2 2
2 2 2 2 2
forcing(m,:)=1
forcing =
1 1 1 1 1
2 2 2 2 2
2 2 2 2 2
1 1 1 1 1
forcing(:,1)=1
forcing =
1 1 1 1 1
1 2 2 2 2
1 2 2 2 2
1 1 1 1 1
forcing(:,n)=1
forcing =
1 1 1 1 1
1 2 2 2 1
1 2 2 2 1
1 1 1 1 1
height=SimplePoisson(xValues,yValues,forcing)
{Undefined function or variable 'SimplePoisson'.}
cd
\\print2.eng.fsu.edu\dommelen\My Documents\MATLAB\METLAB
height=SimplePoisson(xValues,yValues,forcing)
n =
5
m =
4
N =
20
[Warning: Using CONDEST instead of COND for sparse matrix.]
[> In cond (line 25)
In SimplePoisson (line 146)]
solRelerrDueToMatlab =
3.5970e-14
height =
1.0000 1.0000 1.0000 1.0000 1.0000
1.0000 0.9025 0.8751 0.9025 1.0000
1.0000 0.9025 0.8751 0.9025 1.0000
1.0000 1.0000 1.0000 1.0000 1.0000
mesh(xGrid,yGrid,height)