質問

私は3つの配列を持っている、すべて同じサイズます:

xout        % cell array
xin         % numeric array of doubles
b           % logical array

どのように私はbが真であるインデックスに対応し、XINの要素を取り、XOUTに対応する箇所に割り当てることができますか?

>> xout = {'foo', 'bar', 'baz', 'quux'};
>> xin = [1, 2, 3, 4];
>> b = (xin ~= 2);       % yields [1 0 1 1] in this case
>> xout{b}=xin(b);
??? The right hand side of this assignment has too few values 
to satisfy the left hand side.

>> xout(b)=xin(b);
??? Conversion to cell from double is not possible.
役に立ちましたか?

解決

あなたは num2cell の右手を変換する関数を使用する必要がありますxoutに割り当てる前にセルアレイ側

xout(b) = num2cell(xin(b));
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top