How to display this whole data simultaneously?

7 次查看(过去 30 天)
When I run the following code, it displays the data in such a way that it shows the 1st 9 columns in one screen and the remaining 3 columns in other screen. I want to display the whole 12 columns in one screen. How can we do that?
clear;clc
s2=rand(100,1);
s3=rand(100,1);
s4=rand(100,1);
s21=rand(100,1);
s31=rand(100,1);
s41=rand(100,1);
s22=rand(100,1);
s32=rand(100,1);
s42=rand(100,1);
s23=rand(100,1);
s33=rand(100,1);
s43=rand(100,1);
format compact
S=[s2 s3 s4 s21 s31 s41 s22 s32 s42 s23 s33 s43]

回答(1 个)

John D'Errico
John D'Errico 2024-3-3
编辑:John D'Errico 2024-3-3
What can you do? This will mainly be in your MATLAB settings, first, under the command window tab. Here, you can control how many columns the array will be displayed as. So turn off the item "Set matrix display width to eighty columns".
Next, make the command window font smaller. This is in the fonts tab for settings. I leave mine at 12 or even 14 point. Older eyes need bigger numbers. :) But you can go much smaller, and so fit much more into the window space you do have available.
Next, make your command window as wide as possible. Since I have a 27 inch display, that works nicely, so I can be a display hog. But if you have a small laptop, you have less capability there.
Use a short format for numeric display.
format short
x = rand(1,5)
x = 1×5
0.5277 0.1102 0.5668 0.2737 0.4981
Of course, this limits your ability to read the numbers if they vary by orders of magnitude.
And, finally, you can use a tool like sprintf to display the array, giving less space between numbers. That takes a little more effort on your part of course.
disp(sprintf('%0.4g ',x))
0.5277 0.1102 0.5668 0.2737 0.4981
  7 个评论
John D'Errico
John D'Errico 2024-3-3
编辑:John D'Errico 2024-3-3
So what is the problem? Learn to specify the color of a segmented line. You can do that using the function line. And then you can plot the lines in any color you want. Multiple calls to line will plot on the same set of axes. You need not even use the hold command.
For example...
for r = 0:.1:1
line(sort(rand(1,5)),3*r + sort(rand(1,5)),'color',[r,.1,.3])
end
All you need to do now is learn how to control the colors using an RGB triple, so you need to understand the RGB color space.
Sadiq Akbar
Sadiq Akbar 2024-3-4
Thanks alot for your guiadance. I tried it like below, but in vain:
clear;clc
s2=rand(100,1);
s3=rand(100,1);
s4=rand(100,1);
s21=rand(100,1);
s31=rand(100,1);
s41=rand(100,1);
s22=rand(100,1);
s32=rand(100,1);
s42=rand(100,1);
s23=rand(100,1);
s33=rand(100,1);
s43=rand(100,1);
S=[s2 s3 s4 s21 s31 s41 s22 s32 s42 s23 s33 s43];
S=sort(S);
Runs=1:100;
% for r = linspace(0,1,12) %0:.1:1
% line(sort(S),3*r + sort(S),'color',[r,.1,.3],'linewidth',2)
% end
% figure
% semilogy(Runs,S,'linewidth',2)%----------------------(1)
figure
for r = linspace(0,1,12)
semilogy(Runs,S,3*r+S, 'color',[r,.1,.3],'linewidth',2)
end
I want a graph like in (1) i.e. the Runs shoud be along horizontal axis and the values of S should be on vertical axis but logarithmically but with my desired colour or the colour varying like yours. So tried like you but it gives me error.
Error using semilogy
Data must be a single input of y-values or one or more pairs of x- and y-values.
Error in graphDesiredColour3 (line 28)
semilogy(Runs,S,3*r+S, 'color',[r,.1,.3],'linewidth',2)
>>

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Geographic Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by