Is it possible to start to run a Matlab program with a user defined function?
1 回表示 (過去 30 日間)
古いコメントを表示
function demo2(write) if ~exist('write', 'var'), write = false; end; SI =5; SX =6; r = 1.5; sNcut = 0.14; sArea = 120; I = imread('C:\Users\students\Desktop\jo (1)\pi.jpg'); segI = NcutImageSegment(I, SI, SX, r, sNcut, sArea); % show for i=1:length(segI) if ~write figure; imshow(segI{i}); else
imwrite(segI{i}, sprintf('C:\Users\students\Desktop\jo (1)\pi.jpg', i));
end
end
end
It is a function for Normalized cut segmentation.It is being executed directly in the Matlab editor. How is this possible to run directly a user defined function in the Matlab?
1 件のコメント
Jan
2013 年 7 月 30 日
Please format your code properly. This is suggested at least 10 times per day, therefore I'm still puzzled by newcomers, who do not read the instructions before posting a question.
採用された回答
zohar
2013 年 7 月 30 日
Hi JOSHY,
I think you need to create startup.m
and put it in My Documents\MATLAB
At startup, MATLAB contains the statements
if exist('startup')==2
startup
end
that run startup.m. You can extend this process to create additional startup M-files, if needed.
For example
function startup
addpath(...)
demo6(...)
Have fun
0 件のコメント
その他の回答 (2 件)
David Sanchez
2013 年 7 月 30 日
Just type the function name with the right input arguments, then, push enter. Your question is a bit fuzzy, so, I am not sure what is your problem exactly.
0 件のコメント
Jan
2013 年 7 月 30 日
User defined function can be started exactly as the functions shipped in Matlab's toolboxes. See e.g.:
edit std
You see that the std.m file looks like a standard user defined function. And exactly as you would call such builtin functions, you can call your functions also. The only requirement is that the perant folder in contained in Matlab's PATH, see pathtool or addpath.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Software Development Tools についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!