MATLAB: Display parameters in a different window

MATLABprogramming

Suppose I have set a parameter
a=2; b=1;
I want to display these information on a different window (like a plot window). Please advise.

Best Answer

Try this:

a=2; b=1;
figure(1)
plot((1:10), rand(1,10), 'p')
grid
ps = {'a' 'b'};                                             % Define Parameter Names
pv = [2 1];                                                 % Define Parameter Values
for k = 1:numel(pv)
    cstr{k} = sprintf('%s = %.2f', ps{k}, pv(k));           % Cell Array
end
text(7, 0.7, cstr)                                          % Text Output In Plot
Related Question