Undefined Variable for plot
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello, I am am trying to plot the equation "sum" but im not sure what to do with the undefined variable t
clear, clc
for k = 0:9
n = (2*k + 1);
sum = (4/(pi*n))*sin(n*t)
end
plot(sum)
댓글 수: 2
Andrew Reibold
2014년 11월 14일
What is t.
Is it suppose to be time? For what period? Do you know what you are trying to plot? Are you trying to create multiple plots in the same figure, using time as an independant variable (my hypothesis)? Do you have two independant variables with k also being one?
We need the full story to be able to help you
Geoff Hayes
2014년 11월 14일
Also, try not to name your local variables after built-in functions with the same name. Rename your sum variable to total instead.
답변 (1개)
Ali Mohamed
2022년 2월 13일
Make a random vector for t make sure it has 10 elements in order to plot sum vs t
use for example t= 0:1:9
or maybe use linespace
댓글 수: 1
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!