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

2 次查看(过去 30 天)
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 个评论
DGM
DGM 2021-11-7
编辑:DGM 2021-11-7
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.

请先登录,再进行评论。

回答(1 个)

Pramil
Pramil 2024-2-27
编辑:Rena Berman 2024-7-16
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:

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by