Matlab数组操作 [英] Matlab arrays operation

查看:63
本文介绍了Matlab数组操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个大小不同的数组a和b.每个值都包含唯一的值.

I have two arrays, a and b, of different size. Each one contains unique values.

我想比较两者,如果数组b中有数组a的任何值,那么我想将其从b中删除(例如a = [2 3 5]b = [1 8 6 2 3 7],结果b = [1 8 6 7]).

I want to compare both and if any value of array a is in array b, then I want to delete it from b (e.g. a = [2 3 5], b = [1 8 6 2 3 7], results b = [1 8 6 7]).

如何在Matlab中实现它?

How can it be implemented in Matlab?

推荐答案

使用setdiff在一组中查找元素,但不在另一组中.

Use setdiff to find elements in one set but not the other.

setdiff(b, a)

这篇关于Matlab数组操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆