MATLAB

Hi, I need to display an image that's stored in an array. I do the following:

[X,Y]=meshgrid(1:1:10,1:1:10);
f=0.5*(1+0.9*sin(0.2*pi.*X)+0.1*cos(pi.*Y));

and I want to view the image with a title so I was told I can use  the 'show' function like:
show (f*64,'TITLE');
but when I do that, I get an error : "??? Undefined function or variable 'show'."
Why is that happening ?

I can view the image by using imshow(f); but then i cann't add a title.

BTW, I'm using MATAB ver. 5.3.


Arnon David.
LVL 3
arnondAsked:
Who is Participating?
 
ggilmanConnect With a Mentor Commented:
I looked at the Matlab help and they don't have a "show" routine. Could this be a function that the TA wrote and is just calling it from the code? My guess is that he wrote a function that takes the input of a matrix and title and within the routine plots the image and then plots the title.
There is imshow() like you mentioned and you can still use title like I said. I was giving you the way that I thought was best but if you need it as an image, that's fine too. Matlab uses the same title function (as well as many other common functions) for all types of figures. I get a title using the following code. Also just for academic sake, you might look at image() and imagesc(). They make images too.

>> [X,Y]=meshgrid(1:1:10,1:1:10);
>> f=0.5*(1+0.9*sin(0.2*pi.*X)+0.1*cos(pi.*Y));
>> imshow(f)
>> title('mytitle')
0
 
arnondAuthor Commented:
Edited text of question.
0
 
ggilmanCommented:
I don't remember ever seeing a 'show' function in Matlab. Looking at your plot I like mesh(f) or surf(f) better myself. To do a title, use the title command "title('title')". There are other optional parameters for this too if needed. Matlab has online help. Goto help->Help window. For graphs look under  matlab\graph2d or matlab\graph3d. Help on title is under the graph2d. Tested title function on your imshow and it worked.
0
Will You Be GDPR Compliant by 5/28/2018?

GDPR? That's a regulation for the European Union. But, if you collect data from customers or employees within the EU, then you need to know about GDPR and make sure your organization is compliant by May 2018. Check out our preparation checklist to make sure you're on track today!

 
ggilmanCommented:
Try it like this. Looks pretty good. I decreased the step size to show a cleaner curve & used surf instead.

>>[X,Y]=meshgrid(1:.25:10,1:.25:10);
>>f=0.5*(1+0.9*sin(0.2*pi.*X)+0.1*cos(pi.*Y));
>>surf(f)
>>title('My surface plot')
0
 
arnondAuthor Commented:
ggilman, It's supposed to be an image and not a plot (that's why I used imshow(). It's for an image processing course. The TA handed out an exaple and it uses show().

Arnon David.
0
 
ggilmanCommented:
BTW, image() and imagesc() may be part of the image processing toolbox. If you don't have it installed, they probably won't work.
0
 
ggilmanCommented:
On second thought, is that why show() doesn't work? Rather than being a user-written function, you may need a specific toolbox installed. If this is the case, whatever toolbox it is I don't have it either and imshow() is part of image processing so apparently you have that one. I've looked in help and can't find it in any of the other toolboxes either but I guess it's possible.
0
 
arnondAuthor Commented:
I don't know if the show function is something special. I'll have a lesson in a few days so I'll ask the TA what he ment.

Arnon.
0
 
ggilmanCommented:
Well,any news??
0
 
arnondAuthor Commented:
sorry for being so late. The show() function was indeed written by the TA and now he told me to use imshow() and title() to get the same effect. so I reject  your answer and will accept one of the comments that's better suited.

Arnon.
0
All Courses

From novice to tech pro — start learning today.