I want to convert an array to a GPUarray, but Matlab truncates automatically decimals and I don´t get enough precission
Mostrar comentarios más antiguos
Hello,
I want to convert an array to a GPUarray, but Matlab truncates automatically decimals and I don´t get enough precission. I have this simple code:
I have a file CEmb.txt, with this text:
5.0000 1256.7
5.0060 1256.71
5.0120 1256.72
5.0180 1256.73
5.0240 1256.74
5.0300 1256.75
5.0360 1256.76
5.0420 1256.77
5.0480 1256.78
5.0540 1256.79
.... a lot more.
I just type:
> CEmb=load('CEmb.txt');
>CEmb_gpu=gpuArray(CEmb);
Then I create two array of zeros and initialize Volini:
>Vol = zeros(1,6, 'gpuArray');
>Nemb = zeros (1,6, 'gpuArray');
>Volini = 69.788;
And finally I try to interpolate. When I try to do so I receive an error from interp1 that says to me some elements of the array are repeated. This is because gpuArray seems to truncate decimals.
>Vol(1)=Volini;
>Nemb(1)=interp1(CEmb(:,1),CEmb(:,2),Vol(1),'linear');
The error is the following:"Error using gpuArray/interp1
The grid (first argument) must be a finite increasing vector without repeating elements."
I want to know how to improve proper precission. When I analyse the content of CEmb_gpu I see the following:
As you can see we saved 1256.71 but in the gpu Array we obtained 1.2567, we have lost the last decimal!!!, How can we avoid this issue? Thanks in advance.
val = <page truncated: showing [1:500, 1:2] of 3474-by-2>
1.0e+03 *
0.0050 1.2567
0.0050 1.2567
0.0050 1.2567
0.0050 1.2567
0.0050 1.2567
0.0050 1.2568
0.0050 1.2568
0.0050 1.2568
0.0050 1.2568
0.0051 1.2568
[..] It continues
<... display truncated: showed [1:500, :] of 3474×2>
Respuesta aceptada
Más respuestas (2)
Ricardo Herrero
el 5 de Dic. de 2018
0 votos
Ricardo Herrero
el 10 de Dic. de 2018
0 votos
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!