필터 지우기
필터 지우기

Plots for second order control system in the same graph

조회 수: 2 (최근 30일)
Carlos
Carlos 2014년 3월 25일
편집: Paul 2014년 3월 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
Azzi Abdelmalek
Azzi Abdelmalek 2014년 3월 25일
What is the problem?
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에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by