How am I suppose to fix this error. I am trying to run the code in order to get a stress vs strain plot and find the value described in the script.

18 views (last 30 days)
Nick Olibrice
Nick Olibrice on 23 Nov 2021
Edited: per isakson on 24 Nov 2021
clear all
close all
clc
S = readtable("/Users/nickolibrice/Downloads/526projdata.xlsx");
y = S(: , 1); %load
x = S(:, 2); %deflection
Stress = y/(3.14*4*4) ;% r is the original radius of specimen
Strain = (x - lo)/lo % lo is the original length of specimen
plot(strain,stress)
%In the plot of stress strain curve choose any two points before proportionality limit and export it to the workspace as point1 and point2. Now if you enter the point1 in the workspace, then it will show the corresponding stress and strain value. Let the stress and strain at point1 be y1 and x1, similarily for point2 stress and strain be y2 and x2.
Elastic modulus(m) = Stress/Strain = (y2-y1)/(x2-x1)
%Yield point is a point where the stress strain curve and 0.2% offset yield line intersects.
let X = 0.002 : 0.000001 : 0.006
Y = m*(X-0.002)
hold on
plot(X,Y,'r')
%After plotting you will see both offset line graph and previous stress strain curve on the same graph. The intersection of these two graph will be the Yield point.
%Ultimate Strength is the maximum value of stress the specimen can bear.
Ultimate strength = max(Stress)
%Breaking Strength is the stress value at the point of fracture i.e the end point
Breaking strength = Strength(end)
Error using /
Arguments must be numeric, char, or logical.
Error in Finalprojectscript (line 14)
Stress = y/(3.14*4*4) ;% r is the original radius of specimen
  3 Comments
Dyuman Joshi
Dyuman Joshi on 24 Nov 2021
Data type meaning - char/double/string etc.
When you load the excel file and define "y" check in the workspace what it says.

Sign in to comment.

Accepted Answer

per isakson
per isakson on 24 Nov 2021
Edited: per isakson on 24 Nov 2021
This script runs without throwing errors; the syntax is correct. I assigned values to some undefined variables, lo, m, x, y.
Comparing this script with your script will help you spot your errors.
%%
% clear all
% close all
% clc
lo = 1;
m = 1;
% S = readtable("/Users/nickolibrice/Downloads/526projdata.xlsx");
% y = S(: , 1); %load
% x = S(:, 2); %deflection
x = rand(12,1);
y = x + 0.1*rand(12,1);
Stress = y/(3.14*4*4); % r is the original radius of specimen
Strain = (x - lo)/lo; % lo is the original length of specimen
% plot(strain,stress)
plot( Strain, Stress, '+b' )
% In the plot of stress strain curve choose any two points before proportionality limit
% and export it to the workspace as point1 and point2. Now if you enter the point1 in the
% workspace, then it will show the corresponding stress and strain value. Let the stress
% and strain at point1 be y1 and x1, similarily for point2 stress and strain be y2 and x2.
% Elastic modulus(m) = Stress/Strain = (y2-y1)/(x2-x1)
ElasticModulus = Stress/Strain; % = (y2-y1)/(x2-x1);
% Yield point is a point where the stress strain curve and 0.2% offset yield line
% intersects.
% let X = 0.002 : 0.000001 : 0.006 ;
X = 0.002 : 0.000001 : 0.006 ;
Y = m*(X-0.002);
hold on
plot(X,Y,'r')
% After plotting you will see both offset line graph and previous stress strain curve on
% the same graph. The intersection of these two graph will be the Yield point.
% Ultimate Strength is the maximum value of stress the specimen can bear.
% Ultimate strength = max(Stress)
UltimateStrength = max(Stress);
% Breaking Strength is the stress value at the point of fracture i.e the end point
% Breaking strength = Strength(end)
BreakingStrength = Stress(end);

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by