Clear Filters
Clear Filters

HOW DO I MAKE A FUNCTION THAT CHANGES MY FORCE VS. TIME GRAPH TO FORCE VS. POSITION

4 views (last 30 days)
Hello, I plotted a graph that gave me force vs. position but I need to make it so it gives me force vs. time but I am not sure on how to convert the time. I am given the sample rate which is 20 samples per second and the crosspeed is 15 inches per minute. but if the sample rate fluctuates, how can I obtain the actual distance ? I hope this makes sense, anything helps
files = [
"Test 22 Sensor.txt" "Test 22 Instron.TXT";
%%"Test 17 Sensor.txt" "Test 17 Instron.TXT";
];
Valueshift=12.53-6.18;
% value that is adjusted in case the final cross value is not
% correct and the graphs do not match up
SampleRate=10;
% sample rate of the Instron machine
NamedGraphTitle=["2022.03.16 Test 22, .012in Uncoated, 7000lbs, 15in per min"];
TimeendX=20;
%the last value for the axis
% Import the data
for k=1:size(files)
TestSensor = readtable(files(k,1),opts);
TestInstron = readtable(files(k,2),opts_instron);
% transfer the table data to the array
sensor_data = table2array(TestSensor(2:height(TestSensor)-2,:));
instron_data = table2array(TestInstron(2:height(TestInstron),:));
% Plotting
%Pulling Force
plot(sensor_data_shift.*mask,sensor_data(:,3).*mask,'LineWidth',1.5,'Color',[0.267, 0.447, 0.769])% RGB Blue 68, 114, 196
hold on
%Normal Force
plot(instron_data(:,1)/SampleRate+gap,instron_data(:,3),'LineWidth',1.5,'Color',[0.929, 0.490, 0.192])% RGB Orange 237, 125, 49
%Friction
% RGB Grey 165, 165, 165
legend('Normal Force','Pulling Force','Friction*1000')
grid on
title(NamedGraphTitle)
xlabel('Time(s)')
ylabel('Force (lbs)')
axis([16.5,TimeendX,0,7500])
hold off
end
  2 Comments
John D'Errico
John D'Errico on 24 Jun 2022
Sorry, but if all you have is force versus position, then it is provably not possible to know how long it took to move that distance. Time is not possible to derive there, since we have F=m*a. Unless you know the mass of the object, then you cannot recover the acceleration, and therefore, you cannot recover the time taken.
Sulaymon Eshkabilov
Sulaymon Eshkabilov on 24 Jun 2022
Your exercise is solvable but with some approximation. As you have stated that sampling time had some flatuations that you can take as a fixed value approximately. From the given time series and fixed cross-speed, you can calculate the position change that would be approximate, i.e., ts =1/20; Position change: dP = v*ts/60. Since the sampling time was flactuating.

Sign in to comment.

Answers (1)

Aman Banthia
Aman Banthia on 26 Sep 2023
Hi Luis,
I understand that you want to convert a force vs. position graph to a force vs. time graph.
To convert the force vs. position graph to force vs. time, you need to consider the relationship between time and position. Given the sample rate and the cross speed, you can calculate the actual distance covered in each time interval.
Here is how you can approach the conversion:
1. Calculate the time interval between each sample using the sample rate. In this case, the time interval would be 1/20 seconds per sample.
2. Calculate the distance covered in each time interval using the cross speed. Since the cross speed is given in inches per minute, you need to convert it to inches per second. Divide the cross speed by 60 to get the inches per second speed.
3. Multiply the distance covered in each time interval by the number of time intervals to get the total distance covered up to that point.
4. Plot the force vs. time graph using the calculated time intervals and the total distance covered.
Here is an example code snippet to help you understand the conversion process:
% Given parameters
sampleRate = 20; % samples per second
crossSpeed = 15; % inches per minute
% Convert crossSpeed to inches per second
crossSpeed = crossSpeed / 60;
% Calculate time interval per sample
timeInterval = 1 / sampleRate; % seconds
% Calculate distance covered in each time interval
distanceInterval = crossSpeed * timeInterval; % inches
% Calculate total distance covered at each sample
totalDistance = cumsum(distanceInterval);
% Plot the force vs. time graph
force = [10, 15, 20, 18, 12]; % example force data
time = (0:(length(force)-1)) * timeInterval; % calculate time for each sample
plot(time, force);
xlabel('Time (seconds)');
ylabel('Force');
title('Force vs. Time');
In this example, I assumed you have an array of force measurements called ‘force’. Make sure to adjust the code according to your specific data and requirements.
I hope that the above solution helps you.
Best Regards,
Aman Banthia

Categories

Find more on MATLAB in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!