Can I perform subtraction using cell arrays?
13 ビュー (過去 30 日間)
古いコメントを表示
Hi all,
I have 2 sets of numbers which i would like to subtract them and compare their values and perform a counter loop.
Is there any function I can make use of to do that? Thanks
for example I have these 2 sets of numbers which I need to subtract each value and compare:
filteredAreaSample =
3594 3627 3626 3625 3610
filteredAreaStudent =
3648 3621 3613 3620 3626
1 件のコメント
Matt J
2012 年 10 月 14 日
編集済み: Matt J
2012 年 10 月 14 日
It really doesn't make sense for you to maintain data like this in cell arrays. Data like this can be held in simple matrices, making them very simple (and CPU optimized) to subtract
Differences = filteredAreaSample - filteredAreaStudent
Cell arrays are meant mainly for situations where you have arrays of different sizes or types, e.g.,
mycell={rand(5), eye(3),'dog','cat'},
or when you want to perform comma-separated list operations, e.g.,
[A,B,C,D]=deal(mycell{:});
採用された回答
Azzi Abdelmalek
2012 年 10 月 14 日
編集済み: Azzi Abdelmalek
2012 年 10 月 14 日
A ={ 3594 3627 3626 3625 3610}
B ={ 3648 3621 3613 3620 3626}
res=cellfun(@(x,y) y-x,A,B)
10 件のコメント
Azzi Abdelmalek
2012 年 10 月 14 日
編集済み: Azzi Abdelmalek
2012 年 10 月 14 日
Can you be more clear, you have your array Difference, what test do you want to do? And I think you should accept the answer that correspond to your expectation then post another question.
その他の回答 (1 件)
Wayne King
2012 年 10 月 13 日
編集済み: Wayne King
2012 年 10 月 13 日
out = cellfun(@minus,filteredAreaSample,filteredAreaStudent);
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!