Minggu, 21 Juli 2019
KMEANS EXAMPLE
clc
clear all
close all
%% Generate Points
Sigma = [0.5 0.05; 0.05 0.5];
f1 = mvnrnd([0.5 0] ,Sigma,100);
f2 = mvnrnd([0.5 0.5],Sigma,100);
f3 = mvnrnd([0.5 1] ,Sigma,100);
f4 = mvnrnd([0.5 1.5],Sigma,100);
F = [f1;f2;f3;f4];
%% K-means
K = 8; % Cluster Numbers
KMI = 40; % K-means Iteration
CENTS = F( ceil(rand(K,1)*size(F,1)) ,:); % Cluster Centers
DAL = zeros(size(F,1),K+2); % Distances and Labels
CV = '+r+b+c+m+k+yorobocomokoysrsbscsmsksy'; % Color Vector
for n = 1:KMI
for i = 1:size(F,1)
for j = 1:K
DAL(i,j) = norm(F(i,:) - CENTS(j,:));
end
[Distance CN] = min(DAL(i,1:K)); % 1:K are Distance from Cluster Centers 1:K
DAL(i,K+1) = CN; % K+1 is Cluster Label
DAL(i,K+2) = Distance; % K+2 is Minimum Distance
end
for i = 1:K
A = (DAL(:,K+1) == i); % Cluster K Points
CENTS(i,:) = mean(F(A,:)); % New Cluster Centers
if sum(isnan(CENTS(:))) ~= 0 % If CENTS(i,:) Is Nan Then Replace It With Random Point
NC = find(isnan(CENTS(:,1)) == 1); % Find Nan Centers
for Ind = 1:size(NC,1)
CENTS(NC(Ind),:) = F(randi(size(F,1)),:);
end
end
end
%% Plot
clf
figure(1)
hold on
for i = 1:K
PT = F(DAL(:,K+1) == i,:); % Find points of each cluster
plot(PT(:,1),PT(:,2),CV(2*i-1:2*i),'LineWidth',2); % Plot points with determined color and shape
plot(CENTS(:,1),CENTS(:,2),'*k','LineWidth',7); % Plot cluster centers
end
hold off
grid on
pause(0.1)
end
Rabu, 17 Juli 2019
FFT tes WAV
[y, fs] = audioread('Alarm08.wav');
soundsc(y, fs);
subplot(2, 1, 1);
plot(y, 'b-');
grid on;
drawnow;
message = sprintf('Do you want to Set to FFT mode ?');
reply = questdlg(message, 'Toolbox missing', 'Yes', 'No', 'Yes');
if strcmpi(reply, 'No')
% User said No, so exit.
return;
end
lengthOfData = length(y);
nextPowerOfTwo = 2 ^ nextpow2(lengthOfData); % next closest power of 2 to the length
plotScaleFactor = 4;
plotRange = nextPowerOfTwo / 2; % Plot is symmetric about n/2
plotRange = floor(plotRange / plotScaleFactor);
yDFT = fft(y, nextPowerOfTwo); % Discrete Fourier Transform of data
h = yDFT(1:plotRange);
abs_h = abs(h);
freqRange = (0:nextPowerOfTwo-1) * (fs / nextPowerOfTwo); % Frequency range
gfreq = freqRange(1:plotRange); % Only plotting upto n/2 (as other half is the mirror image)
subplot(2, 1, 2);
plot(abs_h, 'b-');
grid on;
drawnow;
soundsc(abs_h, gfreq);
UJI AUDIO REALTIME
d = daq.getDevices
% index Vendor Device ID Description
% ----- ----------- --------- -----------------------------------------------------------------
% 1 directsound Audio0 DirectSound Primary Sound Capture Driver
% 2 directsound Audio1 DirectSound Microphone (High Definition Audio Device)
% 3 directsound Audio2 DirectSound HP 4120 Microphone (2- HP 4120)
% 4 directsound Audio3 DirectSound Microphone (Plantronics .Audio 400 DSP)
% 5 directsound Audio4 DirectSound Digital Audio (S/PDIF) (High Definition Audio Device)
% 6 directsound Audio5 DirectSound Primary Sound Driver
% 7 directsound Audio6 DirectSound Speakers (Plantronics .Audio 400 DSP)
% 8 directsound Audio7 DirectSound HP 4120 (2- HP 4120)
% 9 directsound Audio8 DirectSound Speakers (High Definition Audio Device):1
% 10 directsound Audio9 DirectSound Speakers (High Definition Audio Device):2
%misalkan di laptop kita terdeteksi no 2: 2 directsound Audio1 DirectSound Microphone (High Definition Audio Device)
dev = d(2)
s = daq.createSession('directsound');
addAudioInputChannel(s, dev.ID, 1:2);
s.IsContinuous = true
load chirp.mat;
sound(y, Fs);
hf = figure;
hp = plot(zeros(1000,1));
T = title('Discrete FFT Plot');
xlabel('Frequency (Hz)')
ylabel('|Y(f)|')
grid on;
continuous_fft(y, Fs, hf)
%%REALIMR CONTINUOI
plotFFT = @(src, event) continuous_fft(event.Data, src.Rate, hp);
hl = addlistener(s, 'DataAvailable', plotFFT);
%start
startBackground(s);
figure(hf);
%stop
stop(s);
s.IsContinuous = false;
delete(hl);
%%%%%%%%%%%%%%%%%
function continuous_fft(data, Fs, plotHandle)
lengthOfData = length(data);
nextPowerOfTwo = 2 ^ nextpow2(lengthOfData); % next closest power of 2 to the length
plotScaleFactor = 4;
plotRange = nextPowerOfTwo / 2; % Plot is symmetric about n/2
plotRange = floor(plotRange / plotScaleFactor);
yDFT = fft(data, nextPowerOfTwo); % Discrete Fourier Transform of data
h = yDFT(1:plotRange);
abs_h = abs(h);
freqRange = (0:nextPowerOfTwo-1) * (Fs / nextPowerOfTwo); % Frequency range
gfreq = freqRange(1:plotRange); % Only plotting upto n/2 (as other half is the mirror image)
% whos abs_h
% whos gfreq
set(plotHandle, 'ydata', abs_h, 'xdata', gfreq); % Updating the plot
drawnow; % Update the plot
end
soundsc(y, fs);
subplot(2, 1, 1);
plot(y, 'b-');
grid on;
drawnow;
message = sprintf('Do you want to Set to FFT mode ?');
reply = questdlg(message, 'Toolbox missing', 'Yes', 'No', 'Yes');
if strcmpi(reply, 'No')
% User said No, so exit.
return;
end
lengthOfData = length(y);
nextPowerOfTwo = 2 ^ nextpow2(lengthOfData); % next closest power of 2 to the length
plotScaleFactor = 4;
plotRange = nextPowerOfTwo / 2; % Plot is symmetric about n/2
plotRange = floor(plotRange / plotScaleFactor);
yDFT = fft(y, nextPowerOfTwo); % Discrete Fourier Transform of data
h = yDFT(1:plotRange);
abs_h = abs(h);
freqRange = (0:nextPowerOfTwo-1) * (fs / nextPowerOfTwo); % Frequency range
gfreq = freqRange(1:plotRange); % Only plotting upto n/2 (as other half is the mirror image)
subplot(2, 1, 2);
plot(abs_h, 'b-');
grid on;
drawnow;
soundsc(abs_h, gfreq);
UJI AUDIO REALTIME
d = daq.getDevices
% index Vendor Device ID Description
% ----- ----------- --------- -----------------------------------------------------------------
% 1 directsound Audio0 DirectSound Primary Sound Capture Driver
% 2 directsound Audio1 DirectSound Microphone (High Definition Audio Device)
% 3 directsound Audio2 DirectSound HP 4120 Microphone (2- HP 4120)
% 4 directsound Audio3 DirectSound Microphone (Plantronics .Audio 400 DSP)
% 5 directsound Audio4 DirectSound Digital Audio (S/PDIF) (High Definition Audio Device)
% 6 directsound Audio5 DirectSound Primary Sound Driver
% 7 directsound Audio6 DirectSound Speakers (Plantronics .Audio 400 DSP)
% 8 directsound Audio7 DirectSound HP 4120 (2- HP 4120)
% 9 directsound Audio8 DirectSound Speakers (High Definition Audio Device):1
% 10 directsound Audio9 DirectSound Speakers (High Definition Audio Device):2
%misalkan di laptop kita terdeteksi no 2: 2 directsound Audio1 DirectSound Microphone (High Definition Audio Device)
dev = d(2)
s = daq.createSession('directsound');
addAudioInputChannel(s, dev.ID, 1:2);
s.IsContinuous = true
load chirp.mat;
sound(y, Fs);
hf = figure;
hp = plot(zeros(1000,1));
T = title('Discrete FFT Plot');
xlabel('Frequency (Hz)')
ylabel('|Y(f)|')
grid on;
continuous_fft(y, Fs, hf)
%%REALIMR CONTINUOI
plotFFT = @(src, event) continuous_fft(event.Data, src.Rate, hp);
hl = addlistener(s, 'DataAvailable', plotFFT);
%start
startBackground(s);
figure(hf);
%stop
stop(s);
s.IsContinuous = false;
delete(hl);
%%%%%%%%%%%%%%%%%
function continuous_fft(data, Fs, plotHandle)
lengthOfData = length(data);
nextPowerOfTwo = 2 ^ nextpow2(lengthOfData); % next closest power of 2 to the length
plotScaleFactor = 4;
plotRange = nextPowerOfTwo / 2; % Plot is symmetric about n/2
plotRange = floor(plotRange / plotScaleFactor);
yDFT = fft(data, nextPowerOfTwo); % Discrete Fourier Transform of data
h = yDFT(1:plotRange);
abs_h = abs(h);
freqRange = (0:nextPowerOfTwo-1) * (Fs / nextPowerOfTwo); % Frequency range
gfreq = freqRange(1:plotRange); % Only plotting upto n/2 (as other half is the mirror image)
% whos abs_h
% whos gfreq
set(plotHandle, 'ydata', abs_h, 'xdata', gfreq); % Updating the plot
drawnow; % Update the plot
end
Kamis, 07 Februari 2019
Mencari Edge Image
img = false(5); % Use zeros(5) if you prefer
img(3, 2:4) = true; % use 1 instead of true if you prefer
% Get complement of image, with a border round it in case the
% blob is at the boundary
notimg = true(size(img)+2);
notimg(2:end-1, 2:end-1) = ~img;
% Find locations where a non-zero pixel is adjacent to a zero pixel,
% for each cardinal direction in turn
topedges = img & notimg(1:end-2, 2:end-1);
leftedges = img & notimg(2:end-1, 1:end-2);
bottomedges = img & notimg(3:end, 2:end-1);
rightedges = img & notimg(2:end-1, 3:end);
% Sum each set of locations separately, then add to get total perimeter/Keliling:
perim = sum(topedges(:)) + sum(leftedges(:)) + ...
+ sum(bottomedges(:)) + sum(rightedges(:));
% print result
fprintf('Perimeter is %d\n', perim);
img
img =
5×5 logical array
0 0 0 0 0
0 0 0 0 0
0 1 1 1 0
0 0 0 0 0
0 0 0 0 0
>> topedges
topedges =
5×5 logical array
0 0 0 0 0
0 0 0 0 0
0 1 1 1 0
0 0 0 0 0
0 0 0 0 0
>> rightedges
rightedges =
5×5 logical array
0 0 0 0 0
0 0 0 0 0
0 0 0 1 0
0 0 0 0 0
0 0 0 0 0
>> bottomedges
bottomedges =
5×5 logical array
0 0 0 0 0
0 0 0 0 0
0 1 1 1 0
0 0 0 0 0
0 0 0 0 0
>> leftedges
leftedges =
5×5 logical array
0 0 0 0 0
0 0 0 0 0
0 1 0 0 0
0 0 0 0 0
0 0 0 0 0
notimg =
7×7 logical array
1 1 1 1 1 1 1
1 1 1 1 1 1 1
1 1 1 1 1 1 1
1 1 0 0 0 1 1
1 1 1 1 1 1 1
1 1 1 1 1 1 1
1 1 1 1 1 1 1
IMPLEMENTASI:
I = imread('daun.jpg');
[N,M,L]=size(I);
for n=1:N
for m=1:M
if (I(n,m,1)<225 && I(n,m,2)< 225 && I(n,m,3)<225)
bw1(n,m,1)=255;%I(n,m,1:3);
else
bw1(n,m,1)=0;
end
end
end % bw1 210x210 352800 double
BW = imbinarize(bw1); % BW 210x210 44100 logical
bw2 = imfill(BW,'holes');
figure, imshow(bw2);
s = regionprops(bw2, 'All');
a=s(1,1);
b=s(2,1);
ps=['Luas Area (FilledImage) ' num2str(a.Area) ' px'];
disp(ps);
ps=['Titik Centroid' num2str(a.Centroid(1)) ',' num2str(a.Centroid(2))];
disp(ps);
ps=['Panjang Area ' num2str(a.MajorAxisLength)];
disp(ps);
ps=['Lebar Area ' num2str(a.MinorAxisLength)];
disp(ps);
ps=['Keliling /Perimeter Area ' num2str(a.Perimeter)];
disp(ps);
disp('8 Koordinat Terluar ');
for i = 1:8
ps=['Posisi ' num2str(i) ' : ' num2str(a.Extrema(i,1)) ',' num2str(a.Extrema(i,2))];
disp(ps);
end
Image=a.Image;
FilledImage=a.FilledImage;
M=s.Extrema;
img=~FilledImage;
notimg = true(size(img)+2);
notimg(2:end-1, 2:end-1) = ~img;
hold on
plot(a.Centroid(1), a.Centroid(2), 'r*')
for i = 1:8
plot(M(i,1), M(i,2), 'y*')
end
hold off
figure(2)
leftedges = img & notimg(2:end-1, 3:end);
bottomedges = img & notimg(1:end-2, 2:end-1);
rightedges = img & notimg(2:end-1, 1:end-2);
topedges = img & notimg(3:end, 2:end-1);
perim = sum(topedges(:)) + sum(leftedges(:)) + sum(bottomedges(:)) + sum(rightedges(:));
subplot(2,2,1);
imshow(~rightedges);title('rightedges area');
subplot(2,2,2);
imshow(~topedges);title('topedges area');
subplot(2,2,3);
imshow(~leftedges);title('leftedges area');
subplot(2,2,4);
imshow(~bottomedges);title('bottomedges area');
Luas Area (FilledImage) 60789 px
Titik Centroid156.8662,168.5555
Panjang Area 349.4928
Lebar Area 224.3
Keliling /Perimeter Area 988.042
8 Koordinat Terluar
Posisi 1 : 26.5,2.5
Posisi 2 : 30.5,2.5
Posisi 3 : 287.5,207.5
Posisi 4 : 287.5,208.5
Posisi 5 : 213.5,328.5
Posisi 6 : 210.5,328.5
Posisi 7 : 18.5,6.5
Posisi 8 : 18.5,5.5
IMPLEMENTASI:
I = imread('daun.jpg');
[N,M,L]=size(I);
for n=1:N
for m=1:M
if (I(n,m,1)<225 && I(n,m,2)< 225 && I(n,m,3)<225)
bw1(n,m,1)=255;%I(n,m,1:3);
else
bw1(n,m,1)=0;
end
end
end % bw1 210x210 352800 double
BW = imbinarize(bw1); % BW 210x210 44100 logical
bw2 = imfill(BW,'holes');
figure, imshow(bw2);
s = regionprops(bw2, 'All');
a=s(1,1);
b=s(2,1);
ps=['Luas Area (FilledImage) ' num2str(a.Area) ' px'];
disp(ps);
ps=['Titik Centroid' num2str(a.Centroid(1)) ',' num2str(a.Centroid(2))];
disp(ps);
ps=['Panjang Area ' num2str(a.MajorAxisLength)];
disp(ps);
ps=['Lebar Area ' num2str(a.MinorAxisLength)];
disp(ps);
ps=['Keliling /Perimeter Area ' num2str(a.Perimeter)];
disp(ps);
disp('8 Koordinat Terluar ');
for i = 1:8
ps=['Posisi ' num2str(i) ' : ' num2str(a.Extrema(i,1)) ',' num2str(a.Extrema(i,2))];
disp(ps);
end
Image=a.Image;
FilledImage=a.FilledImage;
M=s.Extrema;
img=~FilledImage;
notimg = true(size(img)+2);
notimg(2:end-1, 2:end-1) = ~img;
hold on
plot(a.Centroid(1), a.Centroid(2), 'r*')
for i = 1:8
plot(M(i,1), M(i,2), 'y*')
end
hold off
figure(2)
leftedges = img & notimg(2:end-1, 3:end);
bottomedges = img & notimg(1:end-2, 2:end-1);
rightedges = img & notimg(2:end-1, 1:end-2);
topedges = img & notimg(3:end, 2:end-1);
perim = sum(topedges(:)) + sum(leftedges(:)) + sum(bottomedges(:)) + sum(rightedges(:));
subplot(2,2,1);
imshow(~rightedges);title('rightedges area');
subplot(2,2,2);
imshow(~topedges);title('topedges area');
subplot(2,2,3);
imshow(~leftedges);title('leftedges area');
subplot(2,2,4);
imshow(~bottomedges);title('bottomedges area');
Luas Area (FilledImage) 60789 px
Titik Centroid156.8662,168.5555
Panjang Area 349.4928
Lebar Area 224.3
Keliling /Perimeter Area 988.042
8 Koordinat Terluar
Posisi 1 : 26.5,2.5
Posisi 2 : 30.5,2.5
Posisi 3 : 287.5,207.5
Posisi 4 : 287.5,208.5
Posisi 5 : 213.5,328.5
Posisi 6 : 210.5,328.5
Posisi 7 : 18.5,6.5
Posisi 8 : 18.5,5.5
Matlab Edge Detection +Crop
rooftops = imread('daun.jpg');
imshow(rooftops);
grayImage = rgb2gray(rooftops);
imshow(grayImage);
[r c] = size(grayImage);
switchfactor = grayImage(round(r/2),round(c/2));
if switchfactor <= 120
minimumCanny = .0025;
maximumCanny = .05;
CFval = .6;
elseif switchfactor <= 150
minimumCanny = .005;
maximumCanny = .075;
CFval = .575;
elseif switchfactor <= 180
minimumCanny = .0075;
maximumCanny = .1;
CFval = .55;
elseif switchfactor <= 210
minimumCanny = .01;
maximumCanny = .125;
CFval = .525;
elseif switchfactor <= 240
minimumCanny = .0125;
maximumCanny = .15;
CFval = .5;
else
minimumCanny = .015;
maximumCanny = .2;
end
%%Active Contour (Overlaying mask and Contour) Works
imshow(grayImage);
hold on
mask = false(size(grayImage));
mask(20:end-20,20:end-20) = true;
visboundaries(mask,'Color','b');
bw = activecontour(grayImage, mask, 200, 'edge','ContractionBias',CFval);
visboundaries(bw,'Color','r');
title('Initial contour (blue) and final contour (red)');
figure, imshow(bw)
title('Segmented Image');
%%Reading the Contour and Specifying the roof
bwNew = grayImage;
bwNew(~bw) = 0;
figure;
imshow(bwNew);
E = entropyfilt(bwNew);
Eim =E;% rescale(E);
figure
imshow(Eim)
BW1 = imbinarize(Eim, .9);
imshow(BW1);
gI2 = bwNew;
gI2(BW1) = 0;
imshow(gI2)
BWf1 = edge(gI2,'canny',[minimumCanny, maximumCanny],sqrt(.075));
BWf2 = edge(bwNew,'canny',[minimumCanny, maximumCanny],sqrt(.075));
%BWf2 = edge(gI2,'zerocross',1,[20,100]);
figure;
imshowpair(BWf1,BWf2,'montage')
title('Textured Normal');
Kamis, 20 Desember 2018
BubbleSort Matlab
>> A=rand(1,8)
A =
0.4505 0.0838 0.2290 0.9133 0.1524 0.8258 0.5383 0.9961
>> B=bubblesort(A)
B =
0.0838 0.1524 0.2290 0.4505 0.5383 0.8258 0.9133 0.9961
Adapun Fungsinya adalah sbb:
function x = bubblesort(x)
n = length(x);
while (n > 0)
nnew = 0;
for i = 2:n
if (x(i) < x(i - 1))
x = swap(x,i,i - 1);
nnew = i;
end
end
n = nnew;
end
end
function x = swap(x,i,j)
val = x(i);
x(i) = x(j);
x(j) = val;
end
A =
0.4505 0.0838 0.2290 0.9133 0.1524 0.8258 0.5383 0.9961
>> B=bubblesort(A)
B =
0.0838 0.1524 0.2290 0.4505 0.5383 0.8258 0.9133 0.9961
Adapun Fungsinya adalah sbb:
function x = bubblesort(x)
n = length(x);
while (n > 0)
nnew = 0;
for i = 2:n
if (x(i) < x(i - 1))
x = swap(x,i,i - 1);
nnew = i;
end
end
n = nnew;
end
end
function x = swap(x,i,j)
val = x(i);
x(i) = x(j);
x(j) = val;
end
Rabu, 19 Desember 2018
Implementasi Matlab Untuk Tingkat kesegaran Ikan
Yuk Kita Buat GUInya :
Jika nanti dijalankan ahsilnya sbb:
Lalu atur propertis nama TAGnya di setiap itemnya
Lalu pada Button kita kasih Koding
Code ahirnya dalah sbb:
function varargout = myGUI(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @myGUI_OpeningFcn, ...
'gui_OutputFcn', @myGUI_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
function myGUI_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
function btnPilih_Callback(hObject, eventdata, handles)
[handles.namafile,handles.direktori]=uigetfile({'*.xls;*.xlsx','file excel(*.xls,*.xlsx)';'*.*','semua file(*.*)'},'buka file xls master');
I=fullfile(handles.direktori,handles.namafile);
if ~isequal(handles.namafile, 0)
set(handles.edPath,'String',I);
[a,b,c]=xlsread(I);
header= {'Kategori', 'Jam', 'Jenis Ikan', 'bagian', 'R', 'G', 'B'};
ba=size(c,1);
co=size(c,2);
mulaike=2;
mydata=c(mulaike:ba,1:co);
rnames = linspace(1,ba-mulaike+1,ba-mulaike+1);
jml=['Total Data Latih ' num2str(ba-1) ' Item']
set(handles.myTabel1,'data',mydata,'ColumnName',header,'RowName',rnames);
set(handles.myTabel1,'Userdata',mydata);
set(handles.txtTotal,'String',jml);
r1=10;
r2=18;
r3=27;
ar1=cell2mat(c(2:r1,5));
ag1=cell2mat(c(2:r1,6));
ab1=cell2mat(c(2:r1,7));
ar2=cell2mat(c(r1+1:r2,5));
ag2=cell2mat(c(r1+1:r2,6));
ab2=cell2mat(c(r1+1:r2,7));
ar3=cell2mat(c(r2+1:r3,5));
ag3=cell2mat(c(r2+1:r3,6));
ab3=cell2mat(c(r2+1:r3,7));
minr1=min(ar1);
ming1=min(ag1);
minb1=min(ab1);
minr2=min(ar2);
ming2=min(ag2);
minb2=min(ab2);
minr3=min(ar3);
ming3=min(ag3);
minb3=min(ab3);
maxr1=max(ar1);
maxg1=max(ag1);
maxb1=max(ab1);
maxr2=max(ar2);
maxg2=max(ag2);
maxb2=max(ab2);
maxr3=max(ar3);
maxg3=max(ag3);
maxb3=max(ab3);
header= {'Kategori', 'Rmin', 'Rmax', 'Gmin', 'Gmax', 'Bmin', 'Bmax'};
rnames = linspace(1,3,3);
mydata2(1,1)={'Segar'};
mydata2(1,2)={minr1};
mydata2(1,3)={maxr1};
mydata2(1,4)={ming1};
mydata2(1,5)={maxg1};
mydata2(1,6)={minb1};
mydata2(1,7)={maxb1};
mydata2(2,1)={'Cukup Segar'};
mydata2(2,2)={minr2};
mydata2(2,3)={maxr2};
mydata2(2,4)={ming2};
mydata2(2,5)={maxg2};
mydata2(2,6)={minb2};
mydata2(2,7)={maxb2};
mydata2(3,1)={'Tidak Segar'};
mydata2(3,2)={minr3};
mydata2(3,3)={maxr3};
mydata2(3,4)={ming3};
mydata2(3,5)={maxg3};
mydata2(3,6)={minb3};
mydata2(3,7)={maxb3};
set(handles.myTabel2,'data',mydata2,'ColumnName',header,'RowName',rnames);
set(handles.myTabel2,'Userdata',mydata2);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
header= {'Linguistic Term', 'R', 'G', 'B'};
rnames = linspace(1,3,3);
mydata3(1,1)={'Low'};
mydata3(1,2)={'10-91'};
mydata3(1,3)={'11-76'};
mydata3(1,4)={'14-87'};
mydata3(2,1)={'Medium'};
mydata3(2,2)={'14-93'};
mydata3(2,3)={'16-90'};
mydata3(2,4)={'27-88'};
mydata3(3,1)={'High'};
mydata3(3,2)={'44-96'};
mydata3(3,3)={'42-93'};
mydata3(3,4)={'41-97'};
set(handles.myTabel3,'data',mydata3,'ColumnName',header,'RowName',rnames);
set(handles.myTabel3,'Userdata',mydata3);
header= {'Linguistic Term', 'Range'};
rnames = linspace(1,3,3);
mydata4(1,1)={'Segar'};
mydata4(1,2)={'11-76'};
mydata4(2,1)={'Cukup Segar'};
mydata4(2,2)={'27-88'};
mydata4(3,1)={'Tidak Segar'};
mydata4(3,2)={'41-97'};
set(handles.myTabel4,'data',mydata4,'ColumnName',header,'RowName',rnames);
set(handles.myTabel4,'Userdata',mydata4);
end
function btnBersih_Callback(hObject, eventdata, handles)
proyek=guidata(gcbo);
mau=questdlg(['Reset ' get(proyek.figure1,'Name')''],['Anda ingin Reset Aplikasi ini?'],'Ya','Tidak','Ya');
if strcmp(mau,'Tidak')
return;
else
%str=date;
%set(handles.edjoindate,'String',str);
set(handles.myTabel1,'data',[],'ColumnName',[],'RowName',[]);
set(handles.myTabel1,'Userdata',[]);
set(handles.myTabel2,'data',[],'ColumnName',[],'RowName',[]);
set(handles.myTabel2,'Userdata',[]);
set(handles.myTabel3,'data',[],'ColumnName',[],'RowName',[]);
set(handles.myTabel3,'Userdata',[]);
set(handles.myTabel4,'data',[],'ColumnName',[],'RowName',[]);
set(handles.myTabel4,'Userdata',[]);
set(handles.edPath,'String','');
set(handles.edMR,'String','');
set(handles.edMG,'String','');
set(handles.edMB,'String','');
set(handles.edPath2,'String','');
set(handles.edHasil1,'String','');
set(handles.edHasil2,'String','');
set(handles.edProses,'String','');
set(handles.txtTotal,'String','Total DataLatih 0 Item');
cla(handles.axes1,'reset');
cla(handles.axes2,'reset');
cla(handles.axes3,'reset');
cla(handles.axes4,'reset');
cla(handles.axes5,'reset');
end
function btnPilih2_Callback(hObject, eventdata, handles)
[handles.namafile,handles.direktori]=uigetfile({'*.jpg;*.bmp','file Image(*.jpg,*.bmp,*.bmp)';'*.*','semua file(*.*)'},'buka file xls master');
I=fullfile(handles.direktori,handles.namafile);
if ~isequal(handles.namafile, 0)
Matrix=imread(I);
set(handles.figure1,'CurrentAxes',handles.axes1);
imshow(Matrix);
set(handles.axes1,'Userdata',Matrix);
MatrixHSV=rgb2hsv(Matrix);
set(handles.figure1,'CurrentAxes',handles.axes5);
imshow(MatrixHSV);
set(handles.axes5,'Userdata',MatrixHSV);
set(handles.btnRGB,'Enable','on');
set(handles.edPath2,'String',I);
end
function btnRGB_Callback(hObject, eventdata, handles)
Matrix=get(handles.axes1,'Userdata');
R=Matrix(:,:,1);
set(handles.figure1,'CurrentAxes',handles.axes2);
imshow(R);
set(handles.axes2,'Userdata',R);
G=Matrix(:,:,2);
set(handles.figure1,'CurrentAxes',handles.axes3);
imshow(G);
set(handles.axes3,'Userdata',G);
B=Matrix(:,:,3);
set(handles.figure1,'CurrentAxes',handles.axes4);
imshow(B);
set(handles.axes4,'Userdata',B);
MR=mean(mean(R));
MG=mean(mean(G));
MB=mean(mean(B));
set(handles.edMR,'String',num2str(MR));
set(handles.edMG,'String',num2str(MG));
set(handles.edMB,'String',num2str(MB));
set(handles.btnRGB,'Enable','off');
function btnExit_Callback(hObject, eventdata, handles)
close;
Minggu, 11 November 2018
Menu Editor Matlab
Setelah membuat halaman kosong + backgroud, agar menarik dan hemat tempat buatlah menu editor
Tools-Menu Editor
Buat link sebagai berikut:
function mnuAdmin_Callback(hObject, eventdata, handles)
admin; %memanggil halaman admin
function mnuEmployes_Callback(hObject, eventdata, handles)
matlabEmploye;%memanggil halaman employee
function mnuValue_Callback(hObject, eventdata, handles)
value;%memanggil halaman value
function mnuAplikasi_Callback(hObject, eventdata, handles)
aplikasi;%memanggil halaman aplikasi
function mnuLogout_Callback(hObject, eventdata, handles)
exit;%keluar aplikasi
CMIIW
Tools-Menu Editor
Buat link sebagai berikut:
function mnuAdmin_Callback(hObject, eventdata, handles)
admin; %memanggil halaman admin
function mnuEmployes_Callback(hObject, eventdata, handles)
matlabEmploye;%memanggil halaman employee
function mnuValue_Callback(hObject, eventdata, handles)
value;%memanggil halaman value
function mnuAplikasi_Callback(hObject, eventdata, handles)
aplikasi;%memanggil halaman aplikasi
exit;%keluar aplikasi
CMIIW
Langganan:
Postingan (Atom)
















