Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
ColorMap + Noisy Double Gaussian + Histogram

Subject: ColorMap + Noisy Double Gaussian + Histogram

From: Michael

Date: 14 Sep, 2013 14:58:09

Message: 1 of 2

Hello everyone,

I have a possibly interesting query! I think my question may be confusing but keep in mind this isn't a math question or an assignment.. I just want to play around a =nd make a pretty image with your help!

I'd like to build a picture of a two gaussians added together (but the peaks far enough away to distinguish).

I'd like to histogram the results :) and then apply something like a different color to every bin (in a rainbow-like order!) ROYGBIV or some cyclic version i.e. red ain't gotta be the first color. But if possible I'd like ot have the ability to cycle the colors (as in ROYGBIV or IVROYGB GBIVROY) in some way would be neat but it may be too difficult or not worth anyone's time!

My starting point is something like:

%% mab double gaussian histogram color
% Same results...
rng('default');

% 1000 samples - should be enough points (even for second gaussian)
oneGaussian = randn(1,1000);

% I need another gaussian (but with different randomly created values...
% But I want to be able to get consistent results each time

% Build Histogram
hist(oneGaussian,59); % 59 is my favorite number and it looks good to me

This isn't much as a starting point, I'm going to keep playing around.. the 'randn' help seems to be pretty great for a lot of this... I'll need to by-hand tune the x location of each gaussian, then I'll probably play around with the height of each (if that's possible, I suppose I could weight each gaussian with another to spread them and stretch them...)

To summarize:
1) Two different shaped (repeatably made) gaussians
2) Histogrammed together so it looks bimodal
3) Add a rainbow/similar color effect across the bins (I know the least about this!)

Thanks in advance!

Truly,
M. A. B.

Subject: ColorMap + Noisy Double Gaussian + Histogram

From: Steven_Lord

Date: 16 Sep, 2013 15:48:54

Message: 2 of 2



"Michael " <mabowles@syr.edu> wrote in message
news:l11ti1$871$1@newscl01ah.mathworks.com...
> Hello everyone,
>
> I have a possibly interesting query! I think my question may be confusing
> but keep in mind this isn't a math question or an assignment.. I just want
> to play around a =nd make a pretty image with your help!
>
> I'd like to build a picture of a two gaussians added together (but the
> peaks far enough away to distinguish).
>
> I'd like to histogram the results :) and then apply something like a
> different color to every bin (in a rainbow-like order!) ROYGBIV or some
> cyclic version i.e. red ain't gotta be the first color. But if possible
> I'd like ot have the ability to cycle the colors (as in ROYGBIV or IVROYGB
> GBIVROY) in some way would be neat but it may be too difficult or not
> worth anyone's time!

*snip*

surf(peaks);
colorbar
for k = 1:length(colormap)
    M = colormap;
    colormap(M([2:end, 1], :)) % move one row to the other end of the
colormap
    pause(0.1)
end

Colormaps in MATLAB are just matrices, and can be manipulated like any other
matrix. You may be interested in the COLORMAPEDITOR, which will let you
tweak to choose exactly your "rainbow" colormap, since I don't think such a
colormap is included with MATLAB.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us