フィルターのクリア

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 Center および File Exchange2-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