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?

 採用された回答

Walter Roberson
Walter Roberson 2016 年 3 月 24 日

0 投票

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

4 件のコメント

Kenneth May
Kenneth May 2016 年 3 月 24 日
編集済み: Kenneth May 2016 年 3 月 24 日
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.
Walter Roberson
Walter Roberson 2016 年 3 月 24 日
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 2016 年 3 月 24 日
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 2016 年 3 月 25 日
Remove the fig2 = figure(2) call. I was not sure that scatterplot would create a figure when it had an existing empty figure.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by