Help to draw a graph of a function.

2 Ansichten (letzte 30 Tage)
zekeriya özkan
zekeriya özkan am 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 Kommentare
Walter Roberson
Walter Roberson am 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 am 29 Mai 2021
How can i solve this problem?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov am 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 Kommentare
zekeriya özkan
zekeriya özkan am 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 am 30 Mai 2021
Bearbeitet: Sulaymon Eshkabilov am 30 Mai 2021
You are MOST Welcome - Ag'a! from Uzbekistan.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Mathematics finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by