MATLAB Answers

How to explore off diagonal elements in matrices without avoiding the for loop?

38 views (last 30 days)
Zeynab Mousavikhamene
Zeynab Mousavikhamene on 15 Apr 2020
Answered: Peng Li on 15 Apr 2020
I need to search if the value of off diagonal elements of many matrices are larger than a specific number. Was wondering if I can do that without using a loop.

Answers (1)

Peng Li
Peng Li on 15 Apr 2020
Not sure if many matrices share the same size. Anyway if you store these matrices in a cell you prob have a chance using cellfun to accomplish this I think. You can use triu or tril to get all off diagonal elements.


Sign in to comment.


Community Treasure Hunt

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

Start Hunting!

Translated by