I Have a code that gives me some output in my command window as a 9 by 80 matrix. I want that when I run the program and it gives me output in the command window, the max and min value should stand outin some way in each column so that I don't have to find them by looking at each row and each column. They could be either bold or underlined or coloured . I dont know how to do it. Or is it even possible?. If not, can you suggest any other way?

댓글 수: 8

Adam
Adam 2015년 2월 10일
bold or underlined in what? There are numerous ways to display data, but by default it is not displayed at all, it is just in a variable.
Do you mean you have a UI with a table of these values or do you want the min and max to be highlighted in the Variable editor?
As far as I know the latter is not possible.
Ace_ventura
Ace_ventura 2015년 2월 10일
편집: Ace_ventura 2015년 2월 10일
is there no way to get max and min values out of matrices of my output file??
Stephen23
Stephen23 2015년 2월 10일
편집: Stephen23 2015년 2월 10일
Your request in not clear, and you keep changing what you are asking for.
In your original question you state that "code that gives me some output as a 9 by 80 matrix": this implies that the matrix exists in MATLAB's workspace. Now you write that the matrices are in "my output file". So now we have to read a file as well? Where is this data, in MATLAB's workspace or in a file? Are we supposed to be able to read your computer screen to know this?
Your original question asked to display some text in an undisclosed location, "either bold or underlined". However you do not say if this is to be printed in the command window, in a GUI or figure, or placed in an image, saved in a file, or printed somewhere else entirely different. So without knowing where you want this "underlined" text, it is difficult to tell you how to do it.
For your latest comment, have you tried reading the min and max documentation?
I recommend that you read this thoroughly:
The 'ix' vector in
[~,ix] = max(A,[],1)
will give the row (1st) index of the maximum value in each column of A, and similarly for the minimums. You should be able to figure out how to use that information to create your display.
Ace_ventura
Ace_ventura 2015년 2월 11일
Sorry guys I was not clear. I have edited my question.
per isakson
per isakson 2015년 2월 11일
편집: per isakson 2015년 2월 11일
That scenario is exactly what my answer addresses! Either you modify your code or, if you cannot do that, capture the output with evalc and print it with a function according to my answer.
Ace_ventura
Ace_ventura 2015년 2월 11일
Thanks per isakson
Stephen23
Stephen23 2016년 1월 11일
See per Isakson's Answer, it actually answers the question asked.

댓글을 달려면 로그인하십시오.

 채택된 답변

Stalin Samuel
Stalin Samuel 2015년 2월 11일

1 개 추천

here i have given a example for you
a = [1:5;6:10;11:15;16:20;21:25]
a=a'
[x y] = size(a)
axis([0 x 0 y])
for i=1:x
for j=1:y
if a(i,j)==max(a(i,:))
text(i,j,[ num2str( a(i,j))],'Fontsize',30)
hold on
else
text(i,j,[ num2str( a(i,j))],'Fontsize',20)
hold on
end
end
end

댓글 수: 2

Ace_ventura
Ace_ventura 2015년 2월 11일
Thanks Stalin
Stephen23
Stephen23 2015년 2월 11일
편집: Stephen23 2015년 11월 4일
@Stalin Samuel: Note that you should not use i or j as loop variable names, as these are the names of the inbuilt imaginary unit.
Also note that consistent indentation makes code easier to follow. Please consider using the MATLAB Editor's default code indentation and formatting in order to make your cod more readable.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

per isakson
per isakson 2015년 2월 10일
편집: per isakson 2015년 2월 10일

3 개 추천

"the max and min value should stand out in each column" &nbsp AKAIK: formatting the output in the command window is not available in the standard Matlab. However, I think it's a good idea and that it can be realized with a small function based on one of these File Exchange contributions
"is there no way to get max and min values out of matrices of my output file??" &nbsp I don't understand this question. The word "file" doesn't appear in the original question. There are functions to calculate min and max.

카테고리

도움말 센터File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

질문:

2015년 2월 10일

댓글:

2016년 1월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by