I need help in creating a stress-load diagram of three different materials

2 views (last 30 days)
I have an assignment where I have three materials Brass, Aluminum and Mild Steel, I have conducted an expeirment of fatigue failure and I have tabulated results of stress and load, now i just need to code in MATLAB in order to produce stress on y axis and load on x axis, hope you can help me out with this
  1 Comment
DGM
DGM on 7 Nov 2021
Edited: DGM on 7 Nov 2021
I'm sure someone has a canonical example of simple 2D plotting, but here's something.
% example x points and y points
hungerpct = 1:100;
bph = (1:100).'.*[2 3] + [0 5] + 5*rand(100,2); % this represents two data series
hp = plot(hungerpct,bph); % plot all series
legend(hp,{'Diddy Kong','Donkey Kong'})
xlabel('Hunger (%)')
ylabel('Banana Consumption Rate (bananas/hour)')
Otherwise, you can share an example of what you've done so far to disambiguate what exactly your data and goals are.

Sign in to comment.

Answers (1)

Pramil
Pramil on 27 Feb 2024
Edited: Rena Berman on 16 Jul 2024
Use the “readtable” function to load the tabulated data into MATLAB and then use the “plot” function to plot the data.
Here is a code example that works in MATLAB version R2018a :
% Read data from the Excel sheet
data = readtable('material_data.xlsx');
% Extract load and stress data for each material
load_data = data{:, 'Load'};
stress_brass = data{:, 'Brass'};
stress_aluminum = data{:, 'Aluminum'};
stress_steel = data{:, 'Mild Steel'};
figure;
% Plot for Brass
plot(load_data, stress_brass, 'o-', 'DisplayName', 'Brass');
hold on; % for plotting all the data in a single plot
% Plot for Aluminum
plot(load_data, stress_aluminum, 's-', 'DisplayName', 'Aluminum');
% Plot for Mild Steel
plot(load_data, stress_steel, 'd-', 'DisplayName', 'Mild Steel');
% Add labels, title, and legend
xlabel('Load');
ylabel('Stress');
title('Stress vs. Load for Different Materials');
legend('show'); % Show legend to identify each dataset
% Release the hold on the current figure
hold off;
You can find the documentation for the “readtable” and “plot” functions through the following links:

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!