Unrecognized function or variable 'filenames'. Error in pengujian_sistem (line 4) jumlah_data = numel(filenames);

1 view (last 30 days)
% membaca file citra dalam folder
image_folder ='data uji';
filename = dir(fullfile(image_folder, '*.jpg'));
jumlah_data = numel(filenames);
% menginiliasisasi variabel data_latih
data_latih = zeros(jumlah_data,5);
% proses ekstraksi ciri orde satu
for k = 1:jumlah_data
full_name = fullfile(image_folder, filenames(k).name);
Img = imread(full_name);
Img = rgb2gray(Img);
H = imhist(Img)';
H = H/sum(H);
I = (0:255);
CiriMEAN = I * H;
CiriENT = -H * log2(H+eps)';
CiriVAR = (I-CiriMean).^2*H';
CiriSKEW = (I-CiriMean).^3*H'/ CiriVAR^1.5;
CiriKURT = (I-CiriMean).^4*H'/ CiriVAR^2-3;
data_latih(k,:) = [CiriMEAN,CiriENT,CiriVAR,CiriSKEW,CiriSKURT];
end
% penentuan nilai target untuk masing-maisng jenis bunga
target_latih = zero(1,jumlah_data);
target_latih(1:6) = 1; %kamboja_biasa
target_latih(7:12) = 2; %kamboja_merah
target_latih(13:18) = 3; %kamboja_plumeriapudica
target_latih(19:24) = 4; %melati-gambir
target_latih(25:30) = 5; %melati_kuning
% pelatihan menggunakan algoritma multivism
output = multivsm(data_latih,target_latih,data_latih);
[n,~] = find(targer_latih==output');
jumlah_benar(1) = sum(n);
akurasi(1) = jumlah_benar(1)/jumlah_data*100;
% load data_latih dan target_latih hasil pelatihan
dl = load('data_latih');
tl = load('target_latih');
% pengujian menggunakan algoritma multivsm
output = multivsm(dl.data_latih,tl.target_latuh,data_uji);
%menghitung nilai akurasi pelatihan
[n,~] = find(targer_latihan==output');
jumlah_benar(2) = sum(n);
akurasi(2) = jumlah_benar(2)/jumlah_data*100;
  3 Comments
dpb
dpb on 26 Apr 2020
As often wont to do, started with just the first comment...that looked bare so ended up as something else. :)

Sign in to comment.

Accepted Answer

dpb
dpb on 26 Apr 2020
filename = dir(fullfile(image_folder, '*.jpg'));
jumlah_data = numel(filenames);
You returned the variable filename (singular) but then used the plural form next line...change one or the other to match.
Since dir() can return multiple and is apparently expected to do so, the plural form would seem the logical choice.
filenames = dir(fullfile(image_folder, '*.jpg'));
  10 Comments
Stephen23
Stephen23 on 28 Apr 2020
"code "multisvm" is not code in matlab ? are you sure ?"
Yes.
Lets search the entire TMW website for the text "multisvm", and see what we find. It is so easy to do, just goto www.mathworks.com and enter your search term in the box at the top that looks like this:
These are currently 46 results, all of which are third-party code submitted on FEX or threads on Answers (several of which ask why multisvm is undefined). None of the results are for any TMW toolbox function. The search feature can also help us by excluding FEX and Answers results, by selecting the advanced search: and then exlcuding FEX and Answers by deselecting the relevant checkboxes:
Which gives these results:
So there we are: once we exclude FEX and Answers from the search, the term "multisvm" cannot be found anywhere on this website. Of course non-existence is impossible to prove, but this is a rather strong hint that multisvm is not a TMW function. Perhaps you prefer your hints stronger than that?

Sign in to comment.

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!