image thumbnail
from Complex Function Grapher by Jon Moller
A tool to graph complex functions on the Argand plane (x + iy).

compfuncgraph2.m
%
%
% Complex function plotter version 2.0
% Kaelyn Willingham
% Jon Moller
% 2011
%
% Graphs complex functions on the Argand plane through inputs and outputs
% Red outputs; blue inputs; lines connect inputs to outputs
%

limA = input('Limiting value for input square array? ');
limB = limA*1i;
selected = input('Number of points between the positive and negative limits? ');
nsteps = selected + 1;
vecA = linspace (-limA, limA, nsteps);
vecB = linspace (-limB, limB, nsteps);
vecBt = transpose(vecB);
matA = repmat(vecA, nsteps, 1);
matBt = repmat(vecBt, 1, nsteps); 
X = matA + matBt;

Y = input('Function to graph? (Use X instead of x; use standard MATLAB functions and operators) ');
strResponse = input('Title for graph? ','s');
lines = input('Connect inputs to outputs with lines? (Y or N) ','s');
markersize = input('Size of markers (9 pt is standard)? ');

input_points = plot(real(X),imag(X),'b.','MarkerSize',markersize); hold on
output_points = plot(real(Y),imag(Y),'r.','MarkerSize',markersize);
input_Group = hggroup;
output_Group = hggroup;
set(input_points,'Parent',input_Group)
set(output_points,'Parent',output_Group)
% Include these hggroups in the legend:
set(get(get(input_Group,'Annotation'),'LegendInformation'),...
    'IconDisplayStyle','on'); 
set(get(get(output_Group,'Annotation'),'LegendInformation'),...
    'IconDisplayStyle','on'); 
legend('Input','Output');

if strcmp(lines,'Y')
    for astep = 1:nsteps
        for bstep = 1:nsteps
            line([real(X(astep,bstep)) real(Y(astep,bstep))], [imag(X(astep,bstep)) imag(Y(astep,bstep))],'Color','k');
        end
    end
end

xlabel('Real');
ylabel('Imaginary');
legend('Input','Output');
title(strResponse);



    






Contact us