how to call a function with multiple output argumnts

조회 수: 1 (최근 30일)
preet
preet 2013년 3월 13일
how to call this function
function [RHist,GHist,BHist]= RGBHistInter(imData);
RHist = [];
GHist = [];
BHist = [];
%extract Red
[Rcounts,x] = imhist(imData(:,:,1),16);
Rtotalpixels = sum(Rcounts);
for j = 1:size(x)
RHist = [RHist Rcounts(j)/Rtotalpixels];
end
%extract Green
[Gcounts,x] = imhist(imData(:,:,2),16);
Gtotalpixels = sum(Gcounts);
for j = 1:size(x)
GHist = [GHist Gcounts(j)/Gtotalpixels];
end
%extract Blue
[Bcounts,x] = imhist(imData(:,:,3),16);
Btotalpixels = sum(Bcounts);
for j = 1:size(x)
BHist = [BHist Bcounts(j)/Btotalpixels];
end
end

채택된 답변

Wayne King
Wayne King 2013년 3월 13일
편집: Wayne King 2013년 3월 13일
From the command line:
[RHist,GHist,BHist]= RGBHistInter(imData);
You just have to save the function RGBHistInter.m in a folder on the MATLAB path. Or, better yet, save it in a folder that you add to the MATLAB path with
>>addpath 'c:\thisisthepath'
or using
>>pathtool
For example, suppose you have a folder called c:\mfiles
>>addpath 'c:\mfiles'
Save the function .m file in that folder and then if you enter
>>which RGBHistInter
you'll see that MATLAB recognizes the function.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Scope Variables and Generate Names에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by