Loop is not running in Matlab

8 visualizaciones (últimos 30 días)
Flower Rose
Flower Rose el 29 de Nov. de 2019
Editada: Flower Rose el 29 de Nov. de 2019
I`m trying to update the variables inside the loop .
I`m sypposed to get a plot where stress and strain respectively as x and y coordinates.Unfortunately i got nothing at all.
Please help.
clc;clear;
%disp('................................Concrete properties');
Fcu=0.3; %input('Ultimate compressive strength(t/cm2)');
Ec=240.9; % Modulus of Elasticity
u=0; % Strain at oroginal point
s=0; %Stress aat original point
uy=-Fcu/Ec; % uy is the concrete strain corresponding to ultimate stress.
%number of steps for strain increment=150
%%%%%%%%%%%% Elastic Branch %%%%%%%%%%%%%%%%%%%
for i=0.0015:-0.0015:0.00001; %deltau is strian increment
if deltau(i)<0 && deltau(i)<uy
factor=(-uy-u(i))/deltau(i);
if factor>1.0 %Elastic Branch
E(i)=Ec;
u(i)=u(i)+deltau(i);
s(i)=s(i)+deltau(i)*Ec;
end
Array=[u(i),s(i)]
plot(u(i),s(i))
hold on

Respuesta aceptada

Stijn Haenen
Stijn Haenen el 29 de Nov. de 2019
There are some errors in your script:
i=0.0015:-0.0015:0.00001;
Only gives the number 0.0015 as output, if you want that i goes from -0.0015 to 0.0015 with steps of 0.00001 use:
i=-0.0015:0.00001:0.0015.
in your for loop i is not an integer so you cannot use deltau(i), the same hold for u(i) and s(i).
maybe you should use this:
i_list=-0.0015:0.00001:0.0015
for i=1:numel(i_list)
...
end
and two 'end' commands are missing in your script.
  1 comentario
Flower Rose
Flower Rose el 29 de Nov. de 2019
Editada: Flower Rose el 29 de Nov. de 2019
Thx for your reply,,
I changed the code as you suggested .Where delta u is a strain increment from( -.0015,-.00149,-.00148.......0.0015) .That`s why i put i in the first place.
Unfortunately,,it gives me error Index exceeds matrix dimensions.
Any thoughts?
Plus,is u=0 and s=0 as intial values iare at the right place in the code?.Beacuse when i tried to remove them,i got undefined function or variable.
P.S ,As (for the two end ),,i have two other loops under the presented one.So i extracted this loop to find out what is wrong.
clc;clear;
%disp('................................Concrete properties');
Fcu=0.3; %input('Ultimate compressive strength(t/cm2)');
Ec=240.9; % Modulus of Elasticity
u=0; % Strain at oroginal point
s=0; %Stress aat original point
uy=-Fcu/Ec; % uy is the concrete strain corresponding to ultimate stress.
%number of steps for strain increment=150
%%%%%%%%%%%% Elastic Branch %%%%%%%%%%%%%%%%%%%
i_deltau=-0.0015:0.00001:0.0015; %deltau is strian increment
for i=1:numel(i_deltau)
if i<0 && i<uy
factor=(-uy-u(i))/i;
if factor>1.0 %Elastic Branch
E(i)=Ec;
u(i)=u(i)+i;
s(i)=s(i)+i*Ec;
end
end
end
Array=[u(i),s(i)]
plot(u(i),s(i))
hold on

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Stress and Strain en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by