Help to draw a graph of a function.

2 ビュー (過去 30 日間)
zekeriya özkan
zekeriya özkan 2021 年 5 月 27 日
編集済み: Sulaymon Eshkabilov 2021 年 5 月 30 日
There was two mistakes. I wrote in a true way. And I want anyone to help me. I studied to draw the graph of function given at the bottom of page. But my drawing is not the same as the expected figure. Please, help how can i correct my MATLAB codes.
clc; clear; clear all;
a=1;
d0=2;
v0=2;
nu=sqrt(2.5);
sumxx=[];
k=100;
for endp=1:k
T=linspace(endp-1,endp,101);
sumx=d0.*cos(nu.*T)+(v0./nu).*sin(nu.*T)+((a.*d0)./nu.^2).*(1-cos(nu.*T));
for n=0:endp-1
K=omega(a,n,nu,v0,d0).*(1-cos(nu.*(T-(n+1))));
sumx=sumx+(a./nu.^2).*K;
end
% sumx=sumx.*x0;
sumxx=[sumxx,sumx];
clear sumx
end
tt=linspace(0,k,k*101);
plot(tt,sumxx)
grid on
hold on
omega.m function is given below;
function w=omega(a,n,nu,v0,d0)
M=[(1-a./(nu.^2)).*cos(nu)+a./(nu.^2) sin(nu)./nu;-nu.*(1-a./(nu.^2)).*sin(nu) cos(nu)];
w=([(1-a./(nu.^2)).*cos(nu)+a./(nu.^2) sin(nu)./nu]*M-[1 0])*(M.^n)*[d0;v0];
end
My function is given like that;
and the expected figure is given like that
  5 件のコメント
Walter Roberson
Walter Roberson 2021 年 5 月 28 日
The requirements are to plot over 0 <= t < m, but the piecewise definition only gives an expression for m <= t < m+1 so we do not know anything about the function over the interval that it is to be plotted over.
zekeriya özkan
zekeriya özkan 2021 年 5 月 29 日
How can i solve this problem?

サインインしてコメントする。

採用された回答

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021 年 5 月 28 日
Hi,
(1) There are some inconsistencies with the initial conditions. As given the formulations can never produce some ripples such uneven points (some uncertainties/noises are present). Since the given formulations are composed of sines and cosines, and thus, the resulting response of the system has to be a smooth plot.
(2) The shown plot is decaying process (reponse) that shows that there is significant damping > 1. With the given data, it is not a decaying process.
In implementation, some parts of the code is not correctly embeded. Here is a corrected code:
...
k=1000;
%for endp=1:k
T=linspace(0,25, 1001);
sumx=d0.*cos(nu.*T)+(v0./nu).*sin(nu.*T)+((a.*d0)./nu.^2).*(1-cos(nu.*T));
for n=0:1000
K=omega(a,n,nu,v0,d0).*(1-cos(nu.*(T-(n))));
sumx=sumx+(a./nu.^2).*K;
end
% sumx=sumx.*x0;
sumxx=[sumxx,sumx];
clear sumx
%end
...
Good luck.
  3 件のコメント
zekeriya özkan
zekeriya özkan 2021 年 5 月 30 日
Dear Sulaymon Eshkabilov;
you wrote true codes instead of my incorrect codes. I put into MATLAB those codes, but it didn't work. I wrote that codes below. The error is at figure at the bottom. Please, help to correct my errors.
a = 1;
nu = 2;
d0 = 0;
v0 = 1;
k=1000;
for endp=1:k
T=linspace(0,25, 1001);
sumx=d0.*cos(nu.*T)+(v0./nu).*sin(nu.*T)+((a.*d0)./nu.^2).*(1-cos(nu.*T));
for n=0:1000
K=omega(a,n,nu,v0,d0).*(1-cos(nu.*(T-(n))));
sumx=sumx+(a./nu.^2).*K;
end
% sumx=sumx.*x0;
sumxx=[sumxx,sumx];
clear sumx
end
tt=linspace(0,k,k*101);
plot(tt,sumxx)
Walter Roberson
Walter Roberson 2021 年 5 月 30 日
Unfortunately we cannot scroll back the image of the command window to see what MATLAB thinks the error is .

サインインしてコメントする。

その他の回答 (1 件)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021 年 5 月 30 日
Hi,
Here is the complete code:
clc; clearvars;
a=1;
d0=2;
v0=2;
nu=sqrt(2.5);
sumxx=[];
k=1000;
T=linspace(0,25, 1001);
sumx=d0.*cos(nu.*T)+(v0./nu).*sin(nu.*T)+((a.*d0)./nu.^2).*(1-cos(nu.*T));
for n=0:1000
K=omega(a,n,nu,v0,d0).*(1-cos(nu.*(T-(n))));
sumx=sumx+(a./nu.^2).*K;
end
SX=sumx;
plot(T,SX)
grid on
hold on
function w=omega(a,n,nu,v0,d0)
M=[(1-a./(nu.^2)).*cos(nu)+a./(nu.^2) sin(nu)./nu;-nu.*(1-a./(nu.^2)).*sin(nu) cos(nu)];
w=([(1-a./(nu.^2)).*cos(nu)+a./(nu.^2) sin(nu)./nu]*M-[1 0])*(M.^n)*[d0;v0];
end
  2 件のコメント
zekeriya özkan
zekeriya özkan 2021 年 5 月 30 日
Dear Friend Suleyman, i am very thankfull to you. Thanks a lot. I am from TURKEY? Where are you from?
Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021 年 5 月 30 日
編集済み: Sulaymon Eshkabilov 2021 年 5 月 30 日
You are MOST Welcome - Ag'a! from Uzbekistan.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by