在MATLAB中绘制椭圆
对于具有以下样式的椭圆的参数方程: 或者可以写成矩阵形式 现在我想用MATLAB中的系数矩阵来画它 方法1:在MATLAB中绘制椭圆,matlab,graph,plot,Matlab,Graph,Plot,对于具有以下样式的椭圆的参数方程: 或者可以写成矩阵形式 现在我想用MATLAB中的系数矩阵来画它 方法1:绘图 function drawEllipse1(mat) t = linspace(0,2*pi,101); vec = [sin(t); cos(t); ones(1,length(t))]; %calculate the coordinates of ellipse ellipse = mat1*vec; ellipseX = ellip
绘图
function drawEllipse1(mat)
t = linspace(0,2*pi,101);
vec = [sin(t); cos(t); ones(1,length(t))];
%calculate the coordinates of ellipse
ellipse = mat1*vec;
ellipseX = ellipse(1,:);
ellipseY = ellipse(2,:);
plot(ellipseX,ellipseY)
end
function drawEllipse2(mat)
syms t;
ellipseExpr = mat*[sin(t); cos(t); 1];
%pass a function handle
ezplot(@(t)ellipseExpr(1),@(t)ellipseExpr(2),[0,2*pi])
end
方法2:ezplot
function drawEllipse1(mat)
t = linspace(0,2*pi,101);
vec = [sin(t); cos(t); ones(1,length(t))];
%calculate the coordinates of ellipse
ellipse = mat1*vec;
ellipseX = ellipse(1,:);
ellipseY = ellipse(2,:);
plot(ellipseX,ellipseY)
end
function drawEllipse2(mat)
syms t;
ellipseExpr = mat*[sin(t); cos(t); 1];
%pass a function handle
ezplot(@(t)ellipseExpr(1),@(t)ellipseExpr(2),[0,2*pi])
end
但是,dravellipse2()
无法正常绘制椭圆?我不知道为什么
mat = [1 2 3;4 5 6];
drawEllipse2(mat)
我不完全确定,但我认为这是因为您是如何传递函数句柄的。 如果你只是简单地做:
ezplot(ellipseExpr(1),ellipseExpr(2),[0,2*pi])
你得到同样的椭圆。