Inserting Variable NAME into plot title

I have created a function [fluence] = fluence_calc(target, bkgrd,t). In the title, I would like to be able to display the user's selection for the target variable and the bkgrd variable. For example: Let's say target is the variable mu_fat and bkgrd is the variable mu_oil. How can I get mu_fat and mu_oil displayed in the title?
Thank you!

 採用された回答

Fangjun Jiang
Fangjun Jiang 2011 年 11 月 16 日

0 投票

use inputname()

4 件のコメント

Kimberly
Kimberly 2011 年 11 月 16 日
I have the following code:
title('Fluence (Target: ', inputname(1),'Background: ', inputname(2))
But I am getting an error. Is there something else I need to include?
Jan
Jan 2011 年 11 月 16 日
If you get an error, posting the message is very helpful in general.
Use square brackets to join the different parts of the string:
title(['Fluence (Target: ', inputname(1),'Background: ', inputname(2)])
Fangjun Jiang
Fangjun Jiang 2011 年 11 月 16 日
I think you need to do
title(['Fluence (Target: ', inputname(1),' Background: ', inputname(2)])
Kimberly
Kimberly 2011 年 11 月 16 日
It worked. Thank you very much.

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

その他の回答 (0 件)

カテゴリ

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by