绘制参数方程

时间:2014-01-19 09:57:28

标签: matlab function plot

我想绘制以下曲线:Ca(t) = (a + cos(t) , -2a^(2) + sin(t)) 目标是为a = -2:0.1:2绘制一些曲线。

clf
a=zeros(1,41);
for i=1:41
    a(i)=-2+(i-1)/10;
    x=linspace(0,2*pi);
    plot([a(i)+cos(x) -2*a(i)^2+sin(x)])
    hold on
    grid on
end

此代码似乎没有完成这项工作。谁能帮我?或者简化我的代码。我知道我可以使用syms选项,但是如何获得a。的所有不同值的图。

2 个答案:

答案 0 :(得分:1)

这实际上是一个很好的数字!

a = (-2:0.1:2)';
t = linspace(0,2*pi,100);

n1 = numel(a);
n2 = numel(t);

Ca1 = repmat(a,1,n2) + repmat(cos(t),n1,1)
Ca2 = repmat(-2*a.^(2),1,n2) + repmat(sin(t),n1,1),

plot(Ca1,Ca2)

enter image description here

答案 1 :(得分:0)

syms t
a=-2:0.1:2;
x=1:length(a);
y=1:length(a);
for i=1:length(a)
    x=a(i)+cos(t);
    y=-2*a(i)^(2)+sin(t);
    hold on
    ezplot(x,y)
end
相关问题