Create a new variable

Hi,
This is a beginners question!! I want to create a new variable: CUENEUTRALONSET that will have the same values than CUEONSETTIME whenever the conditions block and type are '1'
I have tried the following with no success at all:
if all (['Block' == 1, 'Type' == 1])
then CUENEUTRALONSET = CUEONSETTIME(:,1);
end
I have (80*1) double variables in my workplace imported as column vectors from excel: Block, CUEDURATION, CUEONSETTIME, IMAGEONSETTIME, Type
Any suggestion will be highly appreciated.
Thanks so much!!
Victoria

2 件のコメント

Walter Roberson
Walter Roberson 2013 年 3 月 14 日
MATLAB does not use "then"
Victoria
Victoria 2013 年 3 月 14 日
Thanks so much for answering! I have tried it without then and still no success.... V

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

回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 3 月 14 日
編集済み: Azzi Abdelmalek 2013 年 3 月 14 日

0 投票

all (['Block' == 1, 'Type' == 1]) is always false (=0)

5 件のコメント

Victoria
Victoria 2013 年 3 月 14 日
Thanks for the comment, but I am really a beginner, what do you mean by it's always false? How should I indicate matlab the conditions in order to get the values that i want for the new variable? Thanks so much!
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 3 月 14 日
編集済み: Azzi Abdelmalek 2013 年 3 月 14 日
if Block==1 & Type==1
CUENEUTRALONSET = CUEONSETTIME(:,1);
end
Victoria
Victoria 2013 年 3 月 14 日
still not working... any ideas? Thanks so much!
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 3 月 14 日
編集済み: Azzi Abdelmalek 2013 年 3 月 14 日
What are values assigned to Block and Type variables? Can you give more informations about your code
Victoria
Victoria 2013 年 3 月 14 日
編集済み: Azzi Abdelmalek 2013 年 3 月 14 日
So finally I'llmanaged (with help) and the code that works is:
count=0;
CUENEUTRALONSET = zeros(80,1);
for i=1:length(Block==1)
count=count+1;
if Block(i) == 1 && Type(i) == 1
CUENEUTRALONSET(count)=CUEONSETTIME(count);
end
end

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

カテゴリ

ヘルプ センター および File ExchangeImage Processing Toolbox についてさらに検索

タグ

質問済み:

2013 年 3 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by