How to get range of values from a plot?
Show older comments
Hi,
Firstly, I am doubful about getting velocity and acceleration using 'gradient' function instead of 'diff' to get velocity and acceleration from displacement 'y2' in time domain.Is it the correct way to do? secondly, I am trying to get specific range of values from my graph but have no idea how to do?
For example, I just want values in time domain with 0 to 2.5 in x-axis or in between 2.5 to 10, and interpolate to get the perfect nearest one in time axis? I want such portion because I want to add another section of graph from free vibration analysis, this the the response using forced vibration only.
Thanks
Here is my code:
clear all
close all
clc
a=0.5;beta=0.025;wb=14.25;gamma = 1e-10; % introduce gamma
% Define time and frequency axis variables
fs =400; % samples/s
N = 1e6; % number of points
dt = 1 / fs; % s, time step
t = (0:N-1)*dt; % s, time axis
df = 1 / N / dt; % Hz, frequency step
f = (-N/2:N/2-1)*df; % Hz, frequency axis
eta_dom=0.15:0.1:1;
len_eta=length(eta_dom);
len_f=length(f);
X_store=zeros(len_eta,len_f);
% Define function first mode
for j=1:len_eta
eta=eta_dom(j)
y3=sin(pi.*a).*eta.*(1+exp(-1i.*pi.*f./eta))./((-f.^2+(2.*1i).*f.*beta+1).*(eta.^2-i*f*gamma-f.^2));
y4=sin(pi.*a).*eta.*(1+exp(-1i.*pi.*f./eta))./((-f.^2+(2.*1i).*f.*beta+1).*(eta.^2+i*f*gamma-f.^2));
yy = (y3+y4)/2;
%plot original signal
figure(1)
% plot initial time domain signal
plot(f,yy),title('Frequency response');ylabel('Displacement Response of beam');xlabel('Frequency');
grid on
%conversion to time domain
y2 = ifft(ifftshift(yy));
X_store(j,:)=y2;
figure(2)
plot(t,(y2)),title('Time response');ylabel(' Displacement Response of beam');xlabel('Time');hold on;
axis([0 2.5 -0.03 0.03]); % time domain signal after IFFT
grid on
%% To calculate velocity and acceleration
v=gradient(y2);
acc=gradient(v);
figure(3),plot(t,(v)),title('Time response');ylabel('velocity Response of beam');xlabel('Time');hold on;
axis([0 2.5 -0.001 0.001]);
figure(4),plot(t,(acc)),title('Time response');ylabel('acceleration Response of beam');xlabel('Time');%hold on;
axis([0 2.5 -0.00002 0.00002]);
end
figure(5)
cmap=[jet(9)];
for k=1:9
plot(t,X_store(k,:),'color',cmap(k,:),'linewidth',1.5);axis([0 0.7 -0.03 0.03]); hold on;colorbar
end
hold off;
6 Comments
Star Strider
on 4 Apr 2021
Unrecognized function or variable 'eta'.
Error in ... (line ###)
a=0.5;beta=0.025;wb=14.25;gamma = 1e-10; T=pi/(wb*eta);% introduce gamma
.
Susmita Panda
on 4 Apr 2021
Susmita Panda
on 4 Apr 2021
Star Strider
on 4 Apr 2021
Cannot really ignore ‘T’ because of:
Unrecognized function or variable 'T'.
Error in ... (line ###)
dt = 1 / fs;T1=T/dt ; % s, time step
.
Susmita Panda
on 5 Apr 2021
Edited: Susmita Panda
on 5 Apr 2021
Susmita Panda
on 5 Apr 2021
Accepted Answer
More Answers (0)
Categories
Find more on Mathematics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!