I would like to put a character string into title plots. I managed by doing
clear;clc; x = -30:30; y = sin(x); WhatItIs = 'sine curve'; % this is OK plot(x,y) title(sprintf('This is my %s',WhatItIs),'FontSize',14,'FontWeight','bold');
I was happy, but wanted to be a bit fancy --- I want the user to input the string at run time, so I did:
clear;clc;
x = -30:30;
y = sin(x); WhatItIs = input('Please tell us what this is '); % this fails
plot(x,y)
title(sprintf('This is my %s',WhatItIs),'FontSize',14,'FontWeight','bold');
How should I write the line that request user input of a string?