GUI transpose code encounter some errors

4 vues (au cours des 30 derniers jours)
Cristian Martin
Cristian Martin le 10 Mai 2022
Commenté : Cristian Martin le 10 Mai 2022
Hi guys,
I have a code for store and compare photos in a DB and its works fine
clc;
clear all;
close all;
%% Taking an Image
[fname, path]=uigetfile('.jpg');
fname=strcat(path, fname);
im=imread(fname);
im=im2bw(im);
imshow(im);
title('Photo');
answer=inputdlg('Enter the Class(Number from 1-200) ');
str2num(answer{1});
result=ans;
close;
msgbox('Loaded in DB');
%% Feature Extraction
F=FeatureStatistical(im);
try
load db;
F=[F result];
db=[db; F];
save db.mat db
catch
db=[F result]; % 10 200 1
save db.mat db
end
I want to put it in a gui for making an app, but I have this error:
Error: File: load_foto.m Line: 103 Column: 5
"db" previously appeared to be used as a function or command, conflicting with its use here as the name of a variable.
A possible cause of this error is that you forgot to initialize the variable, or you have initialized it implicitly using
load or eval.
The code for thegui loks like this:
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
[fname, path]=uigetfile('.jpg');
fname=strcat(path, fname);
im=imread(fname);
im=im2bw(im);
imshow(im);
title('Photo');
prompt={'Insert class'};
introducere='Input';
num_lines=1;
def={''};
answer=inputdlg(prompt,introducere,num_lines,def);
str2num(answer{1});
result=ans;
close;
msgbox('Succesfully loaded');
%% Feature Extraction
F=FeatureStatistical(im);
try
load db;
F=[F result];
db=[db; F];
save db.mat db
catch
db=[F result]; % 10 200 1
save db.mat db
end
for competition I leave also the Feature statistical code:
function [F]=FeatureStatistical(im)
% Summary of this function goes here
im=double(im);
m=mean(mean(im));
s=std(std(im));
F=[m s];
end

Réponse acceptée

Walter Roberson
Walter Roberson le 10 Mai 2022
load db;
Avoid using that form of load(). Instead, use load as a function assigning to a variable
old = load('db.mat');
db = old.db;
  1 commentaire
Cristian Martin
Cristian Martin le 10 Mai 2022
Thanks Walter ! That's it...

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Produits


Version

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by