From: andrea182 on
and if i want to do the opposit things what i have to do?? for example:
element 99-element 98
element 98-element 97
element 97-element 96...and so on...

Thanks a lot...
From: andrea182 on
and why for example when it do

1.4962 - 1.4961 it give me this number...5,00000000001055e-05

it's wrong???
From: ImageAnalyst on
On Nov 30, 5:55 am, "andrea182 " <nickfasull...(a)yahoo.it> wrote:
> and why for example when it do
>
>  1.4962 - 1.4961 it give me this number...5,00000000001055e-05
>
> it's wrong???
---------------------------------------------------------------------------------------------------------------------
You're probably just not displaying enough digits.
Try putting the line
format('long');
in there and seeing if your input numbers are really that or if
they're being rounded to 4 decimals for display.
Because when I tried to do it, it gave 0.0001 just like it should.
From: ImageAnalyst on
On Nov 30, 4:56 am, "andrea182 " <nickfasull...(a)yahoo.it> wrote:
> and if i want to do the opposit things what i have to do?? for example:
> element 99-element 98
> element 98-element 97
> element 97-element 96...and so on...
>
> Thanks a lot...

----------------------------------------------------------------------------------
Simply reverse the vector:

% Generate vectors of sample data.
vector1 = randperm(15);
vector1(1) = 1.4962;
vector1(2) = 1.4961;
format('long');
disp(vector1); % Display in command window.

% Reverse the array to do the differencing in the order
% element 99-element 98
% element 98-element 97
% element 97-element 96...and so on...
vector1 = vector1(end:-1:1)

% Subtract element i from element (i+1).
diffVector1 = diff(vector1)

% Subtract element (i+1) from element i.
% Note it's the same except a minus sign was added.
% This is what Andrea wants.
diffVector2 = -diff(vector1)
From: Steven Lord on

"andrea182 " <nickfasullo77(a)yahoo.it> wrote in message
news:hf08a7$lsc$1(a)fred.mathworks.com...
> and why for example when it do
>
> 1.4962 - 1.4961 it give me this number...5,00000000001055e-05
>
> it's wrong???

No, it's probably not wrong. See Q6.1 in the newsgroup FAQ linked in my
signature for an explanation, and welcome to the world of floating-point
arithmetic.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ


First  |  Prev  |  Next  |  Last
Pages: 1 2 3
Prev: How use datcomimport
Next: How can plot signal by cwt?