Help to draw a graph of a function.

2 次查看(过去 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.

请先登录,再进行评论。

采纳的回答

Sulaymon Eshkabilov
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
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
You are MOST Welcome - Ag'a! from Uzbekistan.

请先登录,再进行评论。

类别

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

标签

Community Treasure Hunt

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

Start Hunting!

Translated by