MATLAB Answers

Kobi
0

how to round up and down?

Asked by Kobi
on 7 Aug 2014
Latest activity Commented on by Azzi Abdelmalek
on 7 Aug 2014
i have the folowing matrix
ans =
0 0 0 0 -0.2500
0 0 0 0.7500 0
0 0 -0.2500 0 0
0 0.7500 0 0 0
-0.2500 0 0 0 0
i need to round it so the diognal elements are -1 1 -1 1 -1 how can i do this?

  0 Comments

Sign in to comment.

Tags

Products

1 Answer

Answer by Azzi Abdelmalek
on 7 Aug 2014
 Accepted Answer

sign(A).*ceil(abs(A))

  2 Comments

Kobi
on 7 Aug 2014
thanks
Azzi Abdelmalek
on 7 Aug 2014
Or simply
sign(A)

Sign in to comment.