MATLAB Answers

How to generate a normal matrix?

21 views (last 30 days)
Omar B.
Omar B. on 4 Mar 2021
Commented: Omar B. on 5 Mar 2021
How to generate the following matrix in MATLAB? where α is real number, and n is odd number.

Accepted Answer

KALYAN ACHARJYA
KALYAN ACHARJYA on 4 Mar 2021
Edited: KALYAN ACHARJYA on 4 Mar 2021
You can do this in many ways, one way is as follows
Hope, for the last corner mat(1,:)= ....element, you can manipulate:
Sufficient Hints:
alpha=.....;
n=....; % Square Matrix
diag_mat=diag(alpha*ones(1,n));
pattern_data=triu(ones(n),-1).*tril(ones(n),-1);
Add those two matrices
result=...

More Answers (1)

Bjorn Gustavsson
Bjorn Gustavsson on 4 Mar 2021
Have a look at the help and documentation of the diag-function. This question indicates that you're very new to matlab, so you might get up to speed faster if you look through the matlab-onramp material. One of the main skills to learn is to browse efficiently through the help. You should also be able to use the lookfor function to find starting-points for your help-search.
HTH
  3 Comments
Omar B.
Omar B. on 5 Mar 2021
Thank you. I did it.

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