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.
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 Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

질문:

2016년 3월 24일

댓글:

2016년 3월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by