フィルターのクリア

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

12 ビュー (過去 30 日間)
Abdullah Hassan
Abdullah Hassan 2021 年 11 月 7 日
編集済み: Rena Berman 2024 年 7 月 16 日 16:56
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 日 16:56
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 Center および File ExchangeGeographic Plots についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by