Having unimputed data default to a value

Hello, I am writing a function that takes an input and size parameters and exports it as a dot file.
function(input, width, height)
incToDot(KGraph,width,height,1.0,NameofDotFile); (width height are size parameters for the dot file)
I like having the option to change the size parameters in the function but i would also like my function to default so that width and height are not needed. ie if i was simply to type in
function(input)
(it would default to)
incToDot(KGraph,8.0,8.0,1.0,NameofDotFile);

 채택된 답변

Walter Roberson
Walter Roberson 2011년 5월 31일

0 개 추천

Please do not call a variable "input": you will very likely run in to conflicts with the built-in MATLAB function by that name.
function PlotIt(KGraph, width, height)
if ~exist('width', 'var')
width = 8.0;
end
if ~exist('height', 'var')
height = 8.0;
end
incToDot(KGraph,width,height,1.0,NameofDotFile);
end

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Workspace Variables and MAT Files에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by