is my script having 51 equally spaced points?

clc;clear all;
l=25;E=200e9;I=350e-6;w=6e3;
x1=linspace(0,l/2,25)
for n = 1 : length(x1)
y1(n)=(-(w*x1(n))/(384*E*I))*(16*(x1(n)^3)-24*l*(x1(n)^2)+9*(l^3))
end
x2=linspace(l/2,l,26)
for n = 1 : length(x2)
y2(n)=(-(w*x2(n))/(384*E*I))*(8*(x2(n)^3)-24*l*(x2(n)^2) ...
+17*x2(n)*(l^2)-(l^3) )
end
x = [x1, x2];
y = [y1, y2];
plot(x,y, '.')
xlabel('x-axis,length(m)')
ylabel('y-axis,deflection(m)')

댓글 수: 3

I would say, most definitely not equally-spaced! The two functions you are plotting are quartic polynomials in which the derivatives are certainly changing over the interval plotted. Even the x values are not equally-spaced, since there are 25 values in the first half interval and 26 in the second half.
ernest
ernest 2014년 11월 29일
what do u suggest the values i should enter for x to be equally spaced with 51 points. using linspace of course
x = linspace(0,L,51); % I used uppercase L instead of lowercase l
x1 = x(1:25);
x2 = x(26:51);
...

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
Image Analyst 2014년 11월 29일

0 개 추천

If you want them equally spaced along the curve, you'll have to use interparc():
If you just want uniform spacing along the x, then just use linspace on x once.

댓글 수: 5

ernest
ernest 2014년 11월 29일
편집: Image Analyst 2014년 11월 29일
What do you suggest the values I should put for x to have 51 equally spaced points?
Using linspace() of course.
ernest
ernest 2014년 11월 29일
using linspace ofcourse
Image Analyst
Image Analyst 2014년 11월 29일
편집: Image Analyst 2014년 11월 29일
Replace the x2 assignment with this:
deltaX = x1(2) - x1(1)
x2= l/2 : deltaX : 26;
Now x2 will have the same spacing as x1 and your combined [x1,x2] array has 51 elements. Another way using linspace() is to create the whole thing and extract the portions you want for x1 and x2:
x = linspace(0, 26, 51);
x1 = x(1:25);
x2 = x(26:end);
Don't forget to get rid of the x2 assignment in between the for loops if you do it this way!
ernest
ernest 2014년 11월 30일
thanks man. appreciate the help
Image Analyst
Image Analyst 2014년 11월 30일
You're welcome. You can also "Thank" people by Accepting and "Voting" for their answers (to give them reputation points).

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

질문:

2014년 11월 29일

댓글:

2014년 11월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by