defining a variable in matlab

2 次查看(过去 30 天)
V = ((pi*h^2)/3)*((3*r)-h)
plot(h,V)
??? Undefined function or variable 'h'.
Error in ==> p5_22 at 6 V = ((pi*h^2)/3)*((3*r)-h)
I'm sure this is very simple but i forgot how to tell matlab that 'h' is a variable

采纳的回答

CVR
CVR 2013-9-10
hi there, you can use this one
h = 1:1:10 (create variable h from 1 to 10)
  2 个评论
Nicholas
Nicholas 2013-9-10
ok, so since h is now a vector i need to add dots in my equation for it to work...where do i insert them?

请先登录,再进行评论。

更多回答(1 个)

Azzi Abdelmalek
Azzi Abdelmalek 2013-9-10
h=0:0.1:10
r=5
V= (pi*h.^2/3).*(3*r-h)
plot(h,V)

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by