I am having problems to generate a sine-wave Gabor grating. Can someone help please?

1 view (last 30 days)
Hello! I am trying to use a code provided from a book to generate a gabor sine-ave grating stimulus. In this book they suggest we create a function first, called showImage:
%%% Program showImage.m function gca = showImage(M, lut_type) gca = fi gure; % Opens a graphics window image(M); % Display image M in the graphics window axis( ‘ image ’ ); % Sets axis properties of the image in the % graphics window axis( ‘ off ’ ); % Turn off the axes if strcmp(lut_type, ‘ grayscale ’ ) % Check if lut_type is % grayscale lut = [(0:255) ′ (0:255) ′ (0:255) ′ ]/255; colormap(lut); else colormap( ‘ default ’ ); % Use Matlab ’ s default colormap end
The problem is at the fifth last line: lut = [(0:255) ′ (0:255) ′ (0:255) ′ ]/255; the (') symbols seems odd! They appear in 3, not in a even number. Can someone correct this code? Thank you!

Answers (2)

Bob Blaine
Bob Blaine on 15 Dec 2017
Hi Caroline,
I'm not sure of the exact problem that you are having, but if you do the following:
surf(peaks)
lut = [(0:255)' (0:255)' (0:255)' ]/255;
colormap(lut);
You get a nice grayscale display of peaks. The ' mark transposes the number list in the parens so you end up with a matrix with 256 rows and 3 columns. I suspect that there's a syntax problem in your code that I can't see.

Caroline Alencar
Caroline Alencar on 18 Dec 2017
I replaced my "lut" line for yours and it worked! Thank you!

Categories

Find more on Graphics Object Properties in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!