Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.



Pass string to function to increment figure number & figure title
Posted:
Sep 12, 2013 12:32 PM


Dear Colleagues,
I have written a simple function which calculates the tangent to a curve at a single point (x1, y1) and in addition using the central difference method, taking points in front and behind the point of interest for comparison against noisy data (due to using the diff function)
As I will be calling this function many times for a large set of input files, I would like to add two additional inputs to the function, a number, 1,...,n which increments the command
figure( insert number here)
and also a string  i.e. device number which updates the title of the figure
h=title('Results for INPUT DEVICE NUMBER HERE')
I would appreciate any help and thank everyone in advance for theory time and suggestions. Apologies if this is trivial but my exposure to MATLAB is limited.
MATLAB R2012B, Windows 7.
The code is as follows:
__________________________________________________________
function [Central_diff, Exact_point] = Tangent(location, Cdata , Vdata)
%% y = mx + c  Cdata = df*Vdata + C
% Simple central difference approach y2 = Cdata(location+1); y1 = Cdata(location1); x2 = Vdata(location+1); x1 = Vdata(location1); y_x = (y2  y1)/(x2x1); m1 = y_x; c = Cdata(location)  m1*Vdata(location); Central_diff = m1*Vdata+c;
% Exact point tangent y = Cdata; x = Vdata; dy = diff(y); dy = [dy dy(end)]; dx = diff(x); dx = [dx dx(end)]; df = dy./dx; m2 = df(location); % gradient at specified location c = y(location)  x(location)*m2; % y intercept
Exact_point = m2*x + c;
%% Plot figures automatically each time the function is called
figure(1) %replace with string to increment figures per graph generation set(gcf, 'units','normalized','outerposition',[0 0 1 1]); % Maximize figure SetPlotFont('Times',18); %additional *.m file which must be included axis auto set(gca, 'XTick',[8 7 6 5 4 3 2 1 0 1 2 3 4 5 6]) %axis([8 6 0 10e5]) hold all plot(Vdata, Cdata); plot(Vdata, Central_diff,'o'); plot(Vdata, Exact_point,'x'); grid on h=title('CV Curve with Central Difference & Point Tangent INSERT WAFER STRING '); ylabel('Capacitance') xlabel('Gate Voltage [V]'); legend('CV Curve','Central Difference Tangent', 'Exact Tangent')
__________________________________________________________________



