GUI transpose code encounter some errors

1 visualización (últimos 30 días)
Cristian Martin
Cristian Martin el 10 de Mayo de 2022
Comentada: Cristian Martin el 10 de Mayo de 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

Respuesta aceptada

Walter Roberson
Walter Roberson el 10 de Mayo de 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;

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by