a function that draws a plot and uses an input for the title of the plot

3 views (last 30 days)
In my Livescript called test.mlx, I have variables
days
temperatures
I now want to write a function m file that outputs a plot with specification as
plot(days, temperatures)
legend('temperatures')
title('Figure 4. Temperatures')
Then, what I did is to write a function m file called plot1.m
function plot_test(series1, series2, figurenumber)
plot(series1, series2)
legend('series2')
end
Then how should one understand the title part?
  3 Comments
alpedhuez
alpedhuez on 31 May 2020
Yes the question is how to put the file input into this text argument of a function title.
Mohammad junaid
Mohammad junaid on 1 Jun 2020
function plot_test(series1,series2,fignumber)
plot(series1,series2);
l_name = string(series2);
legend(l_name);
t_name=['figure',num2str(fignumber),'.temperatures'];
title(t_name);
end
i hope this wiil help..!

Sign in to comment.

Accepted Answer

KSSV
KSSV on 31 May 2020
figurenumber = 4 ;
title_name = ['Figure',num2str(figurenumber),'.Temperatures'] ;
title(title_name)

More Answers (0)

Tags

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!