I want to give a condition to the values of the x vector , i tried to dosomething but i didnt have teh results i wanted. helpp please

1 view (last 30 days)
w = 0.1;
h = 0.1;
L = 8.0;
E = 210.0E9;
F = 3000.0;
a = L/4;
x = linspace(0,8,100)
I = (w*h^3)/12;%Calculate variable I
R = (F/L)*(L-a);% calculate varibale R
o = ((F*a)/(6*E*I*L))*(2*L-a)*(L-a);% calculate variable o
if (x>a)
y = (-o*x)+(R*(x.^3)/6*E*I)-(F/6*E*I)*(x-a).^3;
else
y = (-o*x)+(R*(x.^3)/6*E*I)-(F/6*E*I)*(0);
endif

Accepted Answer

KSSV
KSSV on 14 Jul 2022
Edited: Torsten on 14 Jul 2022
w = 0.1;
h = 0.1;
L = 8.0;
E = 210.0E9;
F = 3000.0;
a = L/4;
x = linspace(0,8,100) ;
I = (w*h^3)/12;%Calculate variable I
R = (F/L)*(L-a);% calculate varibale R
o = ((F*a)/(6*E*I*L))*(2*L-a)*(L-a);% calculate variable o
y = (-o*x)+(R*(x.^3)/6*E*I)-(F/6*E*I)*(0);
idx = x > a ;
y(idx) = (-o*x(idx))+(R*(x(idx).^3)/6*E*I)-(F/6*E*I)*(x(idx)-a).^3
y = 1×100
1.0e+11 * 0 0.0000 0.0000 0.0001 0.0002 0.0004 0.0007 0.0012 0.0018 0.0025 0.0035 0.0046 0.0060 0.0076 0.0095 0.0117 0.0142 0.0170 0.0202 0.0238 0.0277 0.0321 0.0369 0.0421 0.0479 0.0541 0.0609 0.0681 0.0759 0.0841
With loop. Which can be avoided.
w = 0.1;
h = 0.1;
L = 8.0;
E = 210.0E9;
F = 3000.0;
a = L/4;
x = linspace(0,8,100) ;
I = (w*h^3)/12;%Calculate variable I
R = (F/L)*(L-a);% calculate varibale R
o = ((F*a)/(6*E*I*L))*(2*L-a)*(L-a);% calculate variable o
y = zeros(size(x)) ;
for i = 1:length(x)
if (x(i)>a)
y(i) = (-o*x(i))+(R*(x(i).^3)/6*E*I)-(F/6*E*I)*(x(i)-a).^3;
else
y(i) = (-o*x(i))+(R*(x(i).^3)/6*E*I)-(F/6*E*I)*(0);
end
end
y
y = 1×100
1.0e+11 * 0 0.0000 0.0000 0.0001 0.0002 0.0004 0.0007 0.0012 0.0018 0.0025 0.0035 0.0046 0.0060 0.0076 0.0095 0.0117 0.0142 0.0170 0.0202 0.0238 0.0277 0.0321 0.0369 0.0421 0.0479 0.0541 0.0609 0.0681 0.0759 0.0841
  3 Comments

Sign in to comment.

More Answers (0)

Categories

Find more on C Shared Library Integration in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!