Computing values from a subsection of a data file

1 visualización (últimos 30 días)
Jesse
Jesse el 29 de Dic. de 2011
Greetings all,
As I brush the rust off of MATLAB gradually ;) I'm trying to compute values from a particular data file for a simulation I am doing. The problem is, the results aren't quite right, except for the first value.
So my code is:
z1 = data(1:10,2);
Rz1 = 1/(sqrt(4*z1.^2 + 1))
Now, data(1:10,2) is from my data file where elements 1 through 10 in column 2 are all zero, and according to the equation I stated at Rz1, all the results should be one (so in essence a row of 10 ones). But I get 1 0 0 0 0 0 0 0 0 0 0 as my output, which is not correct.
Can someone point out my mistake? I figure I'll ask this now since my computation gets more complex from here on out, so I want to get it right.
Thanks!
Jesse

Respuesta aceptada

Fangjun Jiang
Fangjun Jiang el 29 de Dic. de 2011
Very close. Just missed one dot.
%z1 = data(1:10,2);
z1=zeros(10,1);
Rz1 = 1./(sqrt(4*z1.^2 + 1))

Más respuestas (0)

Categorías

Más información sobre Data Import and Analysis en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by