Computing values from a subsection of a data file

1 Ansicht (letzte 30 Tage)
Jesse
Jesse am 29 Dez. 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

Akzeptierte Antwort

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

Weitere Antworten (0)

Kategorien

Mehr zu Data Import and Analysis finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by