error while using imshow function.

조회 수: 5 (최근 30일)
sermet
sermet 2013년 7월 13일
답변: Yohana denia 2020년 9월 11일
%I have an empty "axes1" in GUI. I also have an picture in C directory. I want that while fig file opens, this picture can be automatically embed into this axes1. I wrote this code but it fails.
%filename=logo.png
imshow(logo, 'Parent', handles.axes1)
% I wrote this code at the end of my function (% --- Executes just before my_guide_name is made visible.
function my_guide_name_OpeningFcn(hObject, eventdata, handles, varargin)
  댓글 수: 2
Dishant Arora
Dishant Arora 2013년 7월 13일
It would be better if you can specify the error you are getting.
sermet
sermet 2013년 7월 13일
Attempt to execute SCRIPT logo as a function:
C:\Program Files\MATLAB\R2012a\toolbox\matlab\general\logo.m
Error in bursa_wolf>bursa_wolf_OpeningFcn (line 49)
imshow(logo, 'Parent', handles.axes1)
Error in gui_mainfcn (line 221)
feval(gui_State.gui_OpeningFcn, gui_hFigure, [], guidata(gui_hFigure),
varargin{:});
Error in bursa_wolf (line 42)
gui_mainfcn(gui_State, varargin{:});

댓글을 달려면 로그인하십시오.

채택된 답변

Dishant Arora
Dishant Arora 2013년 7월 13일
편집: Dishant Arora 2013년 7월 13일
You should specify full image name(extension too ) within singles quotes. You are getting this error because logo is a predefined command in MATLAB. so you must enclose the name in quotes: 'logo.png'
Moreover,if your image is in directory other than your work directory you should move the image in your work directory or you can use imread to read that image:
I = imread('pathName\fileName');
imshow(I)
  댓글 수: 3
Dishant Arora
Dishant Arora 2013년 7월 13일
I told you to enclose the name in single quotes:
imshow('neu.png', 'Parent', handles.axes1)
sermet
sermet 2013년 7월 14일
ok thanks.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Yohana denia
Yohana denia 2020년 9월 11일
Hello, can i ask u? what's the problem with this?
Error: File: imshow.m Line: 677 Column: 1
The function "adjustXYData" was closed with an
'end', but at least one other function definition
was not. To avoid confusion when using nested
functions, it is illegal to use both conventions in
the same file.

카테고리

Help CenterFile Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by