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?

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 24 Mär. 2016

0 Stimmen

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

4 Kommentare

Kenneth May
Kenneth May am 24 Mär. 2016
Bearbeitet: Kenneth May am 24 Mär. 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
Kenneth May
Kenneth May am 24 Mär. 2016
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!
Walter Roberson
Walter Roberson am 25 Mär. 2016
Remove the fig2 = figure(2) call. I was not sure that scatterplot would create a figure when it had an existing empty figure.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by