I need to make line of best fit in these graphs
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
%S-N Graph Plot for Fatigue Testing for the three specimens
%Defined Parameters
disp('The dimensions and parameters of the Test:');
disp('The diameter for each of the specimen, D=5mm');
disp('The distance from the end of the specimen and the minimum diameter of the specimen, L = 78mm');
D = 5; L = 78;
%The weight that are loaded (kg) are then later converted to Newton (N)
disp('The weight in Newton (N) applied on each of the specimen');
P = [7.580811,9.02244,10.38561,13.20022,14.63204];
disp('Using the Defined Parameters for all the value of (P), the stress is calculated using the formula of stress');
S = [240.8874,286.6965,330.0126,419.4494,464.9469];
%Determining the Number of Cycles done by the three Specimens
disp('The number of cycles done with stress applied and number of trials for Mild Steel');
for k = 1:5
Msteel(k) = input(sprintf('Load Number: %d Cycles Done:', k));
disp(k)
end
disp('The number of cycles done with stress applied of trials for Aluminium');
for d = 1:5
Alum(d) = input(sprintf('Load Number: %d Cycles Done:', d));
disp(d)
end
disp('The number of cycles done with stress applied and number of trials for Brass');
for g = 1:5
Brss(g)= input(sprintf('Load Number: %d Cycles Done:', g));
disp(g)
end
%Arranging allt he values
disp('The Number Of Cycles taken by Aluminium');
disp(Alum);
disp('The Number Of Cycles taken by Mild Steel');
disp(Msteel);
disp('The Number of Cycles taken by Brass');
disp(Brss);
%Plotting the S-N Curve for the three Specimens
%For Aluminium
figure
plot (Alum,S)
title('S-N graph for Aluminium')
xlabel('Number of Cycles (N)')
ylabel('Stress Applied (N/mm^2)')
%For Mild Steel
figure
plot (Msteel,S)
title('S-N graph for Mild Steel')
xlabel('Number of Cycles (N)')
ylabel('Stress Applied (N/mm^2)')
%For Brass
figure
plot (Brss,S)
title('S-N graph for Brass')
xlabel('Number of Cycles (N)')
ylabel('Stress Applied (N/mm^2)')
0 Commenti
Risposte (1)
Avni Agrawal
il 15 Feb 2024
I understand that you want to make a line of best fit. Your MATLAB script looks well-organized and designed to calculate the stress applied on three different specimens and then plot the S-N (Stress-Number of cycles) curves for each material (Aluminium, Mild Steel, and Brass). However, there are a few points to note:
1. Include stress calculations in the script if they depend on the specimen diameter.
2. Ensure cycle input prompts are clear and correctly recorded.
3. Typically, S-N curves have stress on the x-axis and cycles on the y-axis; adjust your plot accordingly.
4. Use `semilogx` or `semilogy` for logarithmic scaling on S-N curves.
Here is a revised version of your script with these points considered:
disp('The dimensions and parameters of the Test:');
D = 5; % Diameter in mm
L = 78; % Length in mm
disp(['The diameter for each of the specimen, D=', num2str(D), 'mm']);
disp(['The distance from the end of the specimen and the minimum diameter of the specimen, L = ', num2str(L), 'mm']);
% The loads applied on each of the specimens in kilograms
loads_kg = [7.580811, 9.02244, 10.38561, 13.20022, 14.63204];
% Convert loads to Newtons (assuming standard gravity)
P = loads_kg * 9.81; % Conversion to Newtons
disp('The weight in Newton (N) applied on each of the specimen:');
disp(P);
% Stress calculation (assuming a formula is used here)
S = [240.8874, 286.6965, 330.0126, 419.4494, 464.9469];
disp('Using the Defined Parameters for all the value of (P), the stress is calculated using the formula of stress');
disp(S);
% Input the number of cycles for each material
Msteel = zeros(1, 5);
Alum = zeros(1, 5);
Brss = zeros(1, 5);
disp('The number of cycles done with stress applied and number of trials for Mild Steel');
for k = 1:5
Msteel(k) = input(sprintf('Load Number: %d Cycles Done:', k));
end
disp('The number of cycles done with stress applied of trials for Aluminium');
for d = 1:5
Alum(d) = input(sprintf('Load Number: %d Cycles Done:', d));
end
disp('The number of cycles done with stress applied and number of trials for Brass');
for g = 1:5
Brss(g) = input(sprintf('Load Number: %d Cycles Done:', g));
end
% Plotting the S-N Curve for the three Specimens
% For Aluminium
figure;
semilogx(Alum, S, '-o');
title('S-N graph for Aluminium');
xlabel('Number of Cycles (N)');
ylabel('Stress Applied (N/mm^2)');
% For Mild Steel
figure;
semilogx(Msteel, S, '-o');
title('S-N graph for Mild Steel');
xlabel('Number of Cycles (N)');
ylabel('Stress Applied (N/mm^2)');
% For Brass
figure;
semilogx(Brss, S, '-o');
title('S-N graph for Brass');
xlabel('Number of Cycles (N)');
ylabel('Stress Applied (N/mm^2)');
This script uses `semilogx` for a semi-logarithmic plot, which is more typical for S-N curves. The `-o` option in the plot command adds markers to the line at each data point, which can make the plot easier to read.
Make sure to replace the stress calculation with the actual formula you are using, and ensure that the units for stress (N/mm^2) are correct based on the calculations.
I hope this helps!
0 Commenti
Vedere anche
Categorie
Scopri di più su Acoustics, Noise and Vibration in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!