Percentage Difference of Values stored in Two Matrices

I have two 40X1 matrices with values in for which I wish to calculate the percentage difference ie. the difference between the first two values, second two values in each etc.
temperature = matrix 1 analtemp = matrix 2
When trying to do a straight forward percentage difference calculation the variable is displayed as a 40X40 matrix with nothing in it:
PDif=100*((temperature-analtemp)/analtemp);
However, it will allow me to calculate the difference (not percentage) between the two as follows:
Dif=temperature-analtemp;
I cannot understand why this is occurring. Is anyone able to offer some assistance?
Thanks

 채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2014년 12월 4일
PDif=100*(temperature-analtemp)./analtemp;

댓글 수: 4

Perfect thanks! Do you mind explaining what the . operator is doing in this case?
[10 20 30]./[2 5 3]
The result is
[10/2 20/5 30/3]
I see. Thanks for your help!
thank you

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

질문:

2014년 12월 4일

댓글:

2022년 2월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by