How to solve the error?
Ältere Kommentare anzeigen
close all;
clear all;
clc;
function [Instances T_target]=create_learning_set()
%%create data set for each texture class
%for cloud class
srcFiles = dir('colored_textures\LearningSet\cloud\*.jpg'); % the folder in which ur images exists
Iin=[]; %this hold the data as input to the neural network
Target=[]; %this holds the target or the required result for each class
%we put it manully.
%read the folder containing the coloud images
for i = 1 : length(srcFiles)
filename = strcat('colored_textures\LearningSet\cloud\',srcFiles(i).name);
I = imread(filename); %read the image
F=get_image_features(I); %create feature vector for the image
Iin=[Iin F']; %concatenate the feature vector to the store of features
Target=[Target, 100];%concatenate the target value for each feature vector
end
%for gravel class
srcFiles = dir('colored_textures\LearningSet\gravel\*.jpg'); % the folder in which ur images exists
for i = 1 : length(srcFiles)
filename = strcat('colored_textures\LearningSet\gravel\',srcFiles(i).name);
I = imread(filename);
F=get_image_features(I); %create feature vector for the image
Iin=[Iin F']; %concatenate the feature vector to the store of features
Target=[Target, 200];%concatenate the target value for each feature vector
end
%for snake skin class
srcFiles = dir('colored_textures\LearningSet\wood\*.jpg'); % the folder in which ur images exists
for i = 1 : length(srcFiles)
filename = strcat('colored_textures\LearningSet\wood\',srcFiles(i).name);
I = imread(filename);
F=get_image_features(I); %create feature vector for the image
Iin=[Iin F']; %concatenate the feature vector to the store of features
Target=[Target, 300];%concatenate the target value for each feature vector
end
T_target=Target;
When I run the code, the error arises
"??? Error: File: create_learning_set.m Line: 5 Column: 1
Function definitions are not permitted in this context.
Error in ==> new_test at 6
[Instances T_target]=create_learning_set();"
How can I solve this?
Akzeptierte Antwort
Weitere Antworten (1)
Walter Roberson
am 17 Jun. 2013
0 Stimmen
Get rid of those first three lines. They are not doing you any good and they are preventing the code from working.
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!