Azzera filtri
Azzera filtri

Computing values from a subsection of a data file

2 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

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

Più risposte (0)

Categorie

Scopri di più su Programming in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by