フィルターのクリア

IF cell of a dataset equal to text

1 回表示 (過去 30 日間)
Matthew
Matthew 2014 年 4 月 15 日
コメント済み: Matthew 2014 年 4 月 17 日
Hi again.
I have a dataset with 100 rows of data with 4 columns.
I am trying to code the following and would like some help please:
For each row
If Table1.column1 = 'FOREX' (which is a string) and Table1.column4 < 0
then return Table1.column3 in Table1.column2
otherwise
If Table1.column1 = 'FOREX' (which is a string) and Table1.column4 >=0
then return Table1.column2 = (1% of Table1.column3) + Table1.column4
End

採用された回答

dpb
dpb 2014 年 4 月 15 日
One (of many) way(s) to write it...
ix=strcmp(T.c1,'FOREX') & T.c4<0;
T(ix).c2=T(ix).c3;
ix=strcmp(T.c1,'FOREX') & T.c4>=0;
T.c2(ix)=0.01*T(ix).c3+T1(ix).c4;
Names abbreviated to protect...
  1 件のコメント
Matthew
Matthew 2014 年 4 月 16 日
Brilliant thank you dpb

サインインしてコメントする。

その他の回答 (1 件)

Matthew
Matthew 2014 年 4 月 16 日
The above worked fine for numeric but I'm having a similar problem when I am wanting replace a field with text in the dataset. Can you help please?
iy=or(strcmp(CtpyList.deal_type,'120'), strcmp(CtpyList.deal_type,'123'));
This works fine and creates the table iy which details 0s or 1s when it meets the above condition.
CtpyList.customer_nr(iy) = CtpyList.Customer_nr_Sec(iy);
This works but it concatenates the cell i.e. customer_nr(iy) now reads: 1 NaN
Note that NaN has been converted to string.
Any ideas on how to totally replace this string NaN with the field in the corresponding row for Customer_nr_Sec??
  6 件のコメント
dpb
dpb 2014 年 4 月 16 日
Good; thought it might.
You do understand why, then???
Matthew
Matthew 2014 年 4 月 17 日
Yes

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLarge Files and Big Data についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by