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)
Show older comments
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
0 Comments
Accepted Answer
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
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
3 Comments
More Answers (0)
See Also
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!