Plots for second order control system in the same graph

5 次查看(过去 30 天)
I'm been trying to graph this equation without success.I keep getting an error message that says:Warning: Imaginary parts of complex X and/or Y arguments ignored.
Note: input is in radiant.
Here is my code:
% Exersice 11
x = input('Please enter vector x in degree: ');
z = [0.1 0.2 0.4 0.7 0.9];
y1 = 1-1/sqrt(1-z(1,1).^2).*exp(-z(1,1).*x).*sin(sqrt(1-z(1,1).^2)).*x+acos(x);
y2 = 1-1/sqrt(1-z(1,2).^2).*exp(-z(1,2).*x).*sin(sqrt(1-z(1,2).^2)).*x+acos(x);
y3 = 1-1/sqrt(1-z(1,3).^2).*exp(-z(1,3).*x).*sin(sqrt(1-z(1,3).^2)).*x+acos(x);
y4 = 1-1/sqrt(1-z(1,4).^2).*exp(-z(1,4).*x).*sin(sqrt(1-z(1,4).^2)).*x+acos(x);
y5 = 1-1/sqrt(1-z(1,5).^2).*exp(-z(1,5).*x).*sin(sqrt(1-z(1,5).^2)).*x+acos(x);
plot(x,y1,x,y2,x,y3,x,y4,x,y5, 'm'), xlabel('x in radiands'), ylabel('y(x)') ,title('1-1/{\surd}(1-\zeta^2)e^-^\zeta^xsin{\surd}(1-\zeta^2)x+cos^-^1(x)'), grid, legend('\zeta = 0.1','\zeta = 0.2','\zeta = 0.4','\zeta = 0.7','\zeta = 0.9')
  2 个评论
Carlos
Carlos 2014-3-25
I should get a sinusoidal graph for each zeta plugged in and what I'm getting is a strange line.
See attached screenshots
<<
>>

请先登录,再进行评论。

采纳的回答

Paul
Paul 2014-3-30
编辑:Paul 2014-3-30
Two things are wrong. One is the parenthesis before .x which should be on the end. The second is the acos(x) which should be acos(z(...)). Also it doesnt make sense that you ask x in degrees while it should be radians:
x = input('Please enter vector x in radians: ');
z = [0.1 0.2 0.4 0.7 0.9];
y1 = 1-(1/sqrt(1-z(1,1).^2)).*exp(-z(1,1).*x).*sin(sqrt(1-z(1,1).^2).*x+acos(z(1,1)));
y2 = 1-1/sqrt(1-z(1,2).^2).*exp(-z(1,2).*x).*sin(sqrt(1-z(1,2).^2).*x+acos(z(1,2)));
y3 = 1-1/sqrt(1-z(1,3).^2).*exp(-z(1,3).*x).*sin(sqrt(1-z(1,3).^2).*x+acos(z(1,3)));
y4 = 1-1/sqrt(1-z(1,4).^2).*exp(-z(1,4).*x).*sin(sqrt(1-z(1,4).^2).*x+acos(z(1,4)));
y5 = 1-1/sqrt(1-z(1,5).^2).*exp(-z(1,5).*x).*sin(sqrt(1-z(1,5).^2).*x+acos(z(1,5)));
figure;
plot(x,y1,x,y2,x,y3,x,y4,x,y5, 'm'), xlabel('x in radiands'), ylabel('y(x)') ,title('1-1/{\surd}(1-\zeta^2)e^-^\zeta^xsin{\surd}(1-\zeta^2)x+cos^-^1(x)'), grid, legend('\zeta = 0.1','\zeta = 0.2','\zeta = 0.4','\zeta = 0.7','\zeta = 0.9')
It would also be easier to just use z(2) instead of z(1,2) etc. and using a for loop like Mischa suggested would save you the copy paste code.

更多回答(1 个)

Mischa Kim
Mischa Kim 2014-3-26
编辑:Mischa Kim 2014-3-26
Carlos, check out
function myDE()
prompt = {'xmin:','xmax:'};
name = 'Input x-range';
numlines = 1;
xlimits = inputdlg(prompt,name,numlines);
N = 100;
x = linspace(str2num(xlimits{1}),str2num(xlimits{2}),N);
z = [0.1 0.2 0.4 0.7 0.9];
hold all
for ii = 1:numel(z)
y = 1 - (1/sqrt(1-z(ii)^2))*exp(-z(ii)*x).*sin(sqrt(1-z(ii)^2)*x...
+ acos(z(ii)));
plot(x,y)
end
end
  1 个评论
Carlos
Carlos 2014-3-29
This is beyond my course scope. Could you simplify using more or less what I have above?
Thanks.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Assembly 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by