clplot2.m

来自「Advanced Engineering Mathematics using M」· M 代码 · 共 20 行

M
20
字号
% CLPLOT2.M Plot an input as 'fn(x.,y.)'. Function must be input as %  a string with matrix variables. Input plot limits in x and y.%  Example:  'x.^2+y.^2+x.*y+2*x+1'clear                  % Clear variables andclf                    %  figures fn=input('Function to minimize -a string using matrices f(x.,y.)=')% Plot the function using the limits inputx0=input('Input the plot limits [xmim xmax ymim ymax]= ')x=[x0(1):.1:x0(2)];    % Create x and y pointsy=[x0(3):.1:x0(4)];%% Use a meshX=x0(1):1:x0(2);Y=x0(3):1:x0(4);[x,y]=meshgrid(X,Y);    % Form matrices for x and yfgrid=eval(fn);         % Form a grid of function values	surfc(x,y,fgrid)        % Plot surface 	xlabel('x')ylabel('y')

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?