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

25 次查看(过去 30 天)
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 个评论
Rohit
Rohit 2022-9-5
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.

请先登录,再进行评论。

回答(1 个)

Drishti
Drishti 2024-8-12,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.

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by