Clear Filters
Clear Filters

Help with Linear Regression & Comparison of 2 Regressions

5 views (last 30 days)
I'm working on taking a large amount of data stored in .csv, then performing some operations with it in MATLAB. It's been several years since I've used MATLAB, so I'm a bit rusty at it - luckily I've made some progress thanks for forums and examples.
Right now I've got plots that are being generated and show what I'm looking for, but I'm struggling to get the information off of them that I need. In essence, my test setup is a sealed vessel that I've got strain gauges on. The plots show pressure on the x-axis and strain on the y-axis; what they show is that there is plastic deformation after the maximum pressure, evident by the strain being different as the pressure is released versus that when pressure is raised. This is ASME BPVC.VIII.1-2021 UG-101[n] if anyone is curious.
I'm needing to generate a curve on the line as pressure is applied, then generate a second curve as pressure is released. I'm not really too sure how to approach that one, i.e. generate two curves on the same set of data but separated by a maximum pressure.
After I have the curves, I then need to compare the two curves to see how much variation there is between them in the form of percent change.
Here is the code I've got thus far, which is merely generating the subplot:
% Input table name from Workspace
dataset = SGTestingTrialIndex108100psi1;
% Parse out individual sensor columns to type DOUBLE
axial = table2array(dataset(: , 2));
maxAxial = max(axial);
circumferential = table2array(dataset(: , 4));
maxCircumferential = max(circumferential);
pressure = table2array(dataset(: , 6));
maxPressure = max(pressure);
% Plot axial values
subplot(2,1,1);
plot(pressure,axial);
xline(maxPressure);
yline(maxAxial);
title('Axial Strain Gauge');
xlabel('Pressure (psi_g)');
ylabel('Axial Strain');
hold on;
% Plot circumferential values
subplot(2,1,2);
plot(pressure,circumferential);
xline(maxPressure);
yline(maxCircumferential);
title('Circumferencial Strain Gauge');
xlabel('Pressure (psi_g)');
ylabel('Circumferential Strain');
And here is the plots that is being generated:
Any help or guidance is greatly appreciated!

Accepted Answer

Drew
Drew on 13 Apr 2023
You could separate the data into 4 parts:
  • circumferential "increasing pressure"
  • circumferential "decreasing pressure"
  • axial "increasing pressure"
  • axial "decreasing pressure"
Then, do regression on each part, and compare them. For the regression analysis, you could use the command line function fitlm, or use the Curve Fitter app, then export the fits to the command line.
  2 Comments
Andrew
Andrew on 13 Apr 2023
Ah, that makes sense. And I could probably separate the data using a FOR loop I would assume, where n = maxPressure. Good thoughts there.
When I run the actual test (what I've shared was generated using a dummy test, as I only get one shot with the real thing) I'll have 12 strain gauge channels, but a properly written FOR loop should handle that pretty well I believe.
Thanks so much!
Drew
Drew on 13 Apr 2023
Since this answer helped you, please remember to "accept" the answer. I mention this because it looks like you are new to MATLAB answers.

Sign in to comment.

More Answers (0)

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!