フィルターのクリア

How can I use the variable name in the WORK PLACE inside a function?

1 回表示 (過去 30 日間)
Doheon Lee
Doheon Lee 2012 年 10 月 13 日
Maybe be my question is a bit ambiguous. I want to use one of variable names in the workplace inside a function.
For example, if I typed RandomNumber=rand(1:4) in the command window, and then a function called 'myplot' was created as below.
function myplot(x);
plot(x); title (x)
end
Then if I type myplot(RandomNumber) in the command window, the plot has a title consisted of numbers (but not the title 'RandomNumber').
How can I use any name inputs to x as a title of plots?
Thank you in advance.
  1 件のコメント
per isakson
per isakson 2012 年 10 月 13 日
編集済み: per isakson 2012 年 10 月 13 日
search for inputname in the help

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

回答 (1 件)

Matt Fig
Matt Fig 2012 年 10 月 13 日
function myplot(x);
plot(x);
title (inputname(1))
end

カテゴリ

Help Center および File ExchangeTitle についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by