필터 지우기
필터 지우기

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 CenterFile Exchange에서 Geographic Plots에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by