defining a variable in matlab

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

1 件のコメント

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 9 月 10 日
what is the value of h?

サインインしてコメントする。

 採用された回答

CVR
CVR 2013 年 9 月 10 日

0 投票

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?
Nicholas
Nicholas 2013 年 9 月 10 日
i got it thank you

サインインしてコメントする。

その他の回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 9 月 10 日

0 投票

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

カテゴリ

ヘルプ センター および File ExchangeMathematics についてさらに検索

タグ

質問済み:

2013 年 9 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by