필터 지우기
필터 지우기

How do you change the look of a graph

조회 수: 1 (최근 30일)
Chris Jordan
Chris Jordan 2015년 5월 16일
댓글: Star Strider 2015년 5월 16일
  댓글 수: 1
Chris Jordan
Chris Jordan 2015년 5월 16일
편집: dpb 2015년 5월 16일
The top plot is what my plot is supposed to look like, the bottom is what my plot actually looks like, hoe do I fix this. Here is my code:
distance = [1:1:7];
for x=1:length(distance)
Tension(x)= (w*lc*lp)/(x*sqrt((lp^2)-(x^2)));
end
plot(distance,Tension,'-o')
title('Distance vs. Tension');
xlabel('Distance, (m)');
ylabel('Tension, (N)');
grid on;

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

채택된 답변

Star Strider
Star Strider 2015년 5월 16일
I don’t have your constants so I can’t reproduce your exact results. This idea does what you want:
w = 3; % Filling Missing Constants
lc = 5; % Filling Missing Constants
lp = 11; % Filling Missing Constants
distance = [0:1:7];
for x=1:length(distance)-1
Tension(x)= (w*lc*lp)/(x*sqrt((lp^2)-(x^2)));
end
distanceP = [zeros(1,length(distance)-1); distance(2:end)];
TensionP = [Tension; zeros(size(Tension))];
plot(distanceP,TensionP,'-o')
title('Distance vs. Tension');
xlabel('Distance, (m)');
ylabel('Tension, (N)');
grid on;
The ‘distanceP’ and ‘TensionP’ are plot matrices that create the correct x and y coordinates to plot. Their construction is relatively straightforward. Take a look at their structures to understand how they work, specifically how they plot each (x,y) pair. Note that it plots each column of each matrix against the corresponding column of the other, taking advantage of MATLAB using column-major addressing.
  댓글 수: 4
Chris Jordan
Chris Jordan 2015년 5월 16일
Thanks a lot.
Star Strider
Star Strider 2015년 5월 16일
My pleasure!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by