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

2 vues (au cours des 30 derniers jours)
Abdullah Hassan
Abdullah Hassan le 7 Nov 2021
Modifié(e) : Rena Berman le 16 Juil 2024
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 commentaire
DGM
DGM le 7 Nov 2021
Modifié(e) : DGM le 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.

Connectez-vous pour commenter.

Réponses (1)

Pramil
Pramil le 27 Fév 2024
Modifié(e) : Rena Berman le 16 Juil 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:

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by