Variable "ON"

조회 수: 2 (최근 30일)
Ferd
Ferd 2012년 3월 21일
Hey
I have 2 arrays, A and B matrices of equal lengths. Now, I need to generate C of same length where,
A = series of zeros with clusters of 10-15values spread out. (Sensor ON readings)
B contains all values. (Fuel amts at all conditions)
So something like,
if A is ON
read those B values
C % doing that calculation
end

채택된 답변

Kye Taylor
Kye Taylor 2012년 3월 21일
First, create C:
C = zeros(size(B));
Then use this command to assign elements of B associated with nonzero A values into the corresponding locations in C:
C(A~=0) = B(A~=0);
If the values in A are not exactly zero but really tiny, then create a threshold
thresh = 1e-6; % 10^(-6) for example
And use this threshold as follows
C(abs(A)>thresh) = B(abs(A)>thresh);
  댓글 수: 1
Ferd
Ferd 2012년 3월 22일
Hey! Yea, it works... thanks!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Geodesy and Mapping에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by