GUI transpose code encounter some errors

1 次查看(过去 30 天)
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