필터 지우기
필터 지우기

Creating a variable depending one another

조회 수: 2 (최근 30일)
Anders
Anders 2013년 3월 16일
Hi!
I want to create one variable depending if another is above or below zero, I currently have the following code;
Buy = r(average>0)
But I want the "Buy" variable to include another variable for when average<0, so that "Buy" consists of r when average>0 and f when average<0. I tried to use help, but I havent found anything to help me yet. If somebody could point me in the right direction it would be greatly appreciated! Thanks!

답변 (1개)

Matt J
Matt J 2013년 3월 16일
편집: Matt J 2013년 3월 16일
What is B when average=0? If I assume it's f, then you could do
B=f;
idx=(average>0);
B(idx) = r(idx);

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by