Help to draw a graph of a function.

2 vues (au cours des 30 derniers jours)
zekeriya özkan
zekeriya özkan le 27 Mai 2021
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 commentaires
Walter Roberson
Walter Roberson le 28 Mai 2021
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 le 29 Mai 2021
How can i solve this problem?

Connectez-vous pour commenter.

Réponse acceptée

Sulaymon Eshkabilov
Sulaymon Eshkabilov le 28 Mai 2021
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 commentaires
zekeriya özkan
zekeriya özkan le 30 Mai 2021
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 le 30 Mai 2021
Unfortunately we cannot scroll back the image of the command window to see what MATLAB thinks the error is .

Connectez-vous pour commenter.

Plus de réponses (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov le 30 Mai 2021
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 commentaires
zekeriya özkan
zekeriya özkan le 30 Mai 2021
Dear Friend Suleyman, i am very thankfull to you. Thanks a lot. I am from TURKEY? Where are you from?
Sulaymon Eshkabilov
Sulaymon Eshkabilov le 30 Mai 2021
Modifié(e) : Sulaymon Eshkabilov le 30 Mai 2021
You are MOST Welcome - Ag'a! from Uzbekistan.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Mathematics dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by