필터 지우기
필터 지우기

Computing values from a subsection of a data file

조회 수: 2 (최근 30일)
Jesse
Jesse 2011년 12월 29일
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

채택된 답변

Fangjun Jiang
Fangjun Jiang 2011년 12월 29일
Very close. Just missed one dot.
%z1 = data(1:10,2);
z1=zeros(10,1);
Rz1 = 1./(sqrt(4*z1.^2 + 1))
  댓글 수: 1
Jesse
Jesse 2011년 12월 29일
Ahh time to pop the champagne! Thanks Fangjun!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by