Clear Filters
Clear Filters

how can I read a graph in the Matlab app? For example, I need the logarithmic decrement of a damping sine oscillation

25 views (last 30 days)
It is about a pendulum test with additional mass.
The pendulum is swinging and I have to find the period and the logarithmic decrement from the graph. The graph is output by an encoder
  1 Comment
Rohit
Rohit on 5 Sep 2022
Hi,
Can you please share the following information: -
  • What encoder is being used in the model?
  • Is App Designer being used to create MATLAB App?
  • Please elaborate on what you mean by “read a graph in MATLAB App”. Do you want the graph data to be imported into the workspace or do you want to display the graph inside the MATLAB App or something else?
Along with this it would be helpful if you can share a reduced model file to understand your query/issue better.

Sign in to comment.

Answers (1)

Drishti
Drishti on 12 Aug 2024 at 10:50
Hi Selim,
I understand that you are facing issue in finding the period and logarithmic decrement of a damping sine oscillation.
To determine the period and logarithmic decrement of a damped sine oscillation, I have generated dummy data simulating an encoder. The parameters used include the sampling frequency, time vector, pendulum frequency, and damping factor.
Furthermore, you can refer to below given code to calculate angle, peaks and logarithmic decrement of wave.
% Generate damped oscillation
% t = time vector, f = frequency of pendulum, time = t
% Generate damped oscillation
angle = exp(-damping * t) .* cos(2 * pi * f * t);
% Find peaks
[peaks, locs] = findpeaks(angle, time, 'MinPeakProminence', 0.05); % Adjust 'MinPeakProminence' as needed
% Calculate the period
periods = diff(locs);
average_period = mean(periods);
% Calculate logarithmic decrement
log_decrements = log(peaks(1:end-1) ./ peaks(2:end));
average_log_decrement = mean(log_decrements); (angle, time, 'MinPeakProminence', 0.05);
For more information, you can refer to the MATLAB Documentation of ‘findpeaks’ function
I hope it helps.

Categories

Find more on App Building 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!