GUI transpose code encounter some errors

조회 수: 1 (최근 30일)
Cristian Martin
Cristian Martin 2022년 5월 10일
댓글: Cristian Martin 2022년 5월 10일
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

채택된 답변

Walter Roberson
Walter Roberson 2022년 5월 10일
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;

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

제품


릴리스

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by