Trouble with displaying gra

Here is my code:
A = load('Data.txt');
histogram(A)
scatterplot(A)
boxplot(A)
(A is a text file of 20 random numbers.)
I need Matlab to show all three of the diagrams, but it only shows two. I am totally new at Matlab, and I have no clue what is incorrect about this code. Anyone know what I did wrong?

 Accepted Answer

A = load('Data.txt');
subplot(1,3,1);
histogram(A)
subplot(1,3,2);
scatterplot(A)
subplot(1,3,3)
boxplot(A)

4 Comments

Kenneth May
Kenneth May on 24 Mar 2016
Edited: Kenneth May on 24 Mar 2016
It still only pulled up two windows... however this time it displayed the histogram and boxplot. Alongside the histogram it brought up a blank table.
You appear to be using scatterplot() from the Communications Systems toolbox. It is restricted to using its own figure, not to using the current axes.
A = load('Data.txt');
fig = figure(1);
ax1 = subplot(1,2,1, 'Parent', fig);
histogram(ax1, A);
title('histogram')
ax2 = subplot(1,2,2);
boxplot(ax2, A);
title('boxplot')
fig2 = figure(2);
scatterplot(A)
title('scatterplot')
If the scatterplot comes up empty, it could be that your data is not very suitable for a scatterplot
That did the trick. Oddly enough, it now brings up three separate figures, one of which is blank, but all of the information is there.
Thanks!
Remove the fig2 = figure(2) call. I was not sure that scatterplot would create a figure when it had an existing empty figure.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!