How to add Lower Triangular Matrix to Upper Matrix in matlab

How to add Lower Triangular Matrix to Upper Matrix in matlab  

Please Check ... code .. I  m trying to add all the lower triangular part to upper triangular
part of matrix , so that zeros are substituted in lower triangular part ...
h = magic(6);
disp(h) ;
th =  triu(h);
disp(th);

indexthL = find (~triu(h));
indexthU = find (triu(h));



thU =  triu(h) ;
thL =  tril(h,-1) ;

Open in new window

Puneet AroraFounderAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

yuk99Commented:
I don't understand the question.

I've checked the code. There is some redundancy (like th and thU are the same thing, and instead of disp you could just remove ";" from the end of a statement), but all statements are correct. What are you trying to do again?
0
yuk99Commented:
If you add lower part (thL) to upper part (thU) you will get the original matrix h, so h == thL + thU will return true. I keep reading the question and still have no idea what you want to do.
0
yuk99Commented:
Sorry, I meant isequal(h,thU+thL).
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Puneet AroraFounderAuthor Commented:
Please check the File attached ,


I need to add the Values of Lower Triangular to upper Triangular , if you check  doc

The zeros mean .., that I need to add Values from Lower Part to Upper Triangular part at that place

Solution.odt
0
Puneet AroraFounderAuthor Commented:
In case you need a  doc format of the file attached in my last comment  Solution.doc
0
Puneet AroraFounderAuthor Commented:

Dear


The Matrix is Symmetric (18 X 18) , Need to add to upper matrix and the lower part , and substitute the
values of Lower matrix with zeros .. ,  
0
yuk99Commented:
I think you want to transpose (switching rows with columns, in other words) the result of tril and add it to some matrix.

Let's sey you want to add lower part of h to h:
h2 = h + triu(h');
or equally
h2 = h + tril(h)';

If you don't want to add the diagonal, use the 2nd parameter:
h2 = h + triu(h',1);
or equally
h2 = h + tril(h,-1)';
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.