hi i write this matlap code but when i plot it i get an empty graph

조회 수: 4 (최근 30일)
vt=-7; w=0.47; L=0.025; m=1.22; c0=34.515e-9;k=(w*m*c0/(2*L));
for vg=0:10:40
Id=k*(vg-vt).^2
plot(vg,Id,'r');
hold on;
end

채택된 답변

Walter Roberson
Walter Roberson 2018년 1월 16일
Change the 'r' to 'r*'
  댓글 수: 2
shaker mahmood
shaker mahmood 2018년 1월 16일
thank you for your help but why its only show a points while it has to be a curve
Walter Roberson
Walter Roberson 2018년 1월 16일
You only ask it to plot one point at a time. MATLAB has no way of knowing that you want the points to be connected. If you want points to be connected in a plot then you need to give plot at least two points, the place to draw from and the place to draw to.
All of which is leading to the fact that you should not be plotting inside the loop. Instead you should be calculating the coordinates and storing them in a vector, and then you can plot the vector after the loop.

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

추가 답변 (1개)

shaker mahmood
shaker mahmood 2018년 1월 16일
thank you

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by