Hello, I'm trying to make some calculation with vectors and matrix, with functions as sin, cos and operators, but comparing with excell...it gives me differences of 0,0004...I have tried with vpa, but...anyone can help me please?

teta_transmis(1,1)=teta+beta(1);%calculul primei orientari
if teta_transmis(1,1) > 400
teta_transmis(1,1)=teta_transmis(1,1)-400;
end
n=length(beta);
for i=2:n
teta_transmis(i,1)=vpa(teta_transmis(i-1,1)+200+beta(i),50);
if teta_transmis(i,1)>400
teta_transmis(i,1)=vpa(teta_transmis(i,1)-400,50);
end;
end;

6 Comments

vpa() only applies to symbolic calculations.
How different are the answers you see?
I have made the differences and it gives me the 0.0004 value...it remains constant... I don't know how to explain why...
"I have made the differences" &nbsp How have you done that?
a comparison between the resulted numbers from matlab and those from excell...they are different with 0,0004
Could it a result of rounding errors in the presentation?
I have made the same calculation in excell and the result is different from Matlab and I don't know why...

Sign in to comment.

 Accepted Answer

This is an extremely common error made by people.
Usually this has happened not because of the computations, but because of the precision of the numbers as transferred over. For example, suppose you have a number like 1.0243 in Excel. What too many people do is to TYPE it into MATLAB as 1.0243. The problem is, Excel actually was carrying more precision than that. It was surely not the actual number. So what happens is you did the computations in MATLAB with the wrong numbers.
Why do I think this is what you have done? Because you have reported an essentially constant error, regardless of whether you used higher precision to do the computations.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!