필터 지우기
필터 지우기

Plotting 2D graph problem with x-axis spacing.

조회 수: 1 (최근 30일)
Ryan Rizzo
Ryan Rizzo 2018년 3월 17일
편집: KALYAN ACHARJYA 2018년 3월 17일
I want to plot y = 2*exp((t.^2/)2) in MATLAB in the range of 0 to 3. I can't seem to get the vector length correctly and getting:
error using plot. Vectros must be the same length.
I understand that the vectors need to be the same length, but cannot actually implement this.
Code:
x = 0:0.1:3;
y = 2*(exp((t.^(2))/2));
plot (x,y,'r');
Without the 'x variable, the plot comes to:
plot (y,'r');
Comparing this to an online plotting tool for
gives:
Which does not seem to be exactly what I am getting as a result in MATLAB.
  1. Is the equation for plotting written correctly?
  2. How do I get the x-axis to range from 0 to 3?
Many thanks for any suggestions.
  댓글 수: 2
KALYAN ACHARJYA
KALYAN ACHARJYA 2018년 3월 17일
편집: KALYAN ACHARJYA 2018년 3월 17일
From the above expression, x is independent with y. And what about the x range. Clarify "A Spacing" means?
Ryan Rizzo
Ryan Rizzo 2018년 3월 17일
편집: Ryan Rizzo 2018년 3월 17일
Yes, I see that x is independent w.r.t y. I simply want to get the x-axis range from 0 to 3. I will edit my question. That was a typo from my end

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

채택된 답변

KALYAN ACHARJYA
KALYAN ACHARJYA 2018년 3월 17일
편집: KALYAN ACHARJYA 2018년 3월 17일
%Note: range t from - to +
t=-2:0.1:2;
%x=-3:0.1:3;
y=2.*(exp((t.^(2))/2));
plot(t,y,'linewidth',3);

추가 답변 (0개)

카테고리

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