Say I had a variable called "x" and x=5.
I would like to do:
disp('x is equal to ' + x +'.');
and have that code print:
x is equal to 5.
This is how I am used to doing things in Java, so their must be a similar way to do this in MATLAB.
Thanks
If you want to use
disp, you can construct the string to display like so:I personally prefer to use
fprintf, which would use the following syntax (and gives me some control over formatting of the value of x)You can, of course, also supply
xas string, and get the same output asdisp(give or take a few line breaks).