Filter löschen
Filter löschen

illogical graph values when plotting shear diagram

3 Ansichten (letzte 30 Tage)
Ali Ramadan
Ali Ramadan am 29 Mär. 2020
Kommentiert: Image Analyst am 29 Mär. 2020
I am trying to solve the following problem where i need to plot the shear diagram but in deed when ever i try to plot my graph it comes with illogical values
i am forced to use the function calc with no change to it (thats the only condition ) i can only change my script and in what context do i call my function
am getting the following graph
My script :
clc;
clear all;
w=2;
EI=1e6;
L=10;
x=linspace(0,L,1000)
a1=1;
an=4;
UDL=an-a1;
a=linspace(a1,an,1000);
dis=linspace(1,L,1000);
for i=1:length(a)
res=calc(dis(i),L,[w a(i)],EI);
v(i)=res(1);
m(i)=res(2);
y(i)=res(3);
end
plot(x,v);
the function calc :(should not change anyhting in it)
function [ res ] = calc( x,L,Load,EI )
%it is used to find the shear moment and deflection
%for a simply supported beam in 2 cases
% UDL, point load
if length(Load)==1 %UDL
P=Load;
res(1) = P*L/2-P*x;
res(2) = P*L/2*x-P*x ^2/2;
res(3) = -P*x/(24*EI)*(L^3-2*L*x^2+x^3);
elseif length(Load)==2 %Point load
F=Load(1);
a=Load(2);
b=L-a;R1=F*b/L;R2=F*a/L;
if x <= a
res(1) = R1;
res(2) = R1*x;
res(3) = -F*b*x/(6*L*EI)*(L^2-x^2-b^2);
else
res(1) = -R2;
res(2) = R1*x -F*(x-a);
res(3) = -F*b/(6*L*EI)*(L/b*(x-a)^3+(L^2-b^2)*x-x^3);
end
else
res=[];
end
end

Antworten (1)

Image Analyst
Image Analyst am 29 Mär. 2020
Your x is just a single value, not a list of every x location for each v location. But you can leave it out and just plot x as the index number:
plot(v, 'b-');
  2 Kommentare
Ali Ramadan
Ali Ramadan am 29 Mär. 2020
i updated it the code and inserted the graph that am getting but in deeed its illogical , the shear diagram should be a staright line then a decrease of y=ax+b form then continue as a straight line and it should decrease by 2 overall , which is not happening any ideas?
Image Analyst
Image Analyst am 29 Mär. 2020
It IS a line, followed by a decrease/drop of about 2, then another line. At around x = 1.2, the y goes from about 1.75 to -0.25, which is a drop of 2. I have no idea about the physics of that program - it just looks like an uncommented, alphabet soup to me. You maybe can take it up with your professor.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by