在MATLAB中定义其他infix运算符 [英] Defining additional infix operators in MATLAB

查看:81
本文介绍了在MATLAB中定义其他infix运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以在MATLAB中定义其他的中缀运算符?

Is there a way to define additional infix operators in MATLAB?

具体来说,我想定义两个中缀运算符-><->(这些符号是理想的,但是如果需要可以是单个字符),它们在函数中调用函数impliesiff. &调用and+调用plus的方式相同.

Specifically, I'd like to define two infix operators -> and <-> (these symbols would be ideal, but it could be a single character if necessary), which call functions implies and iff in the same way that & calls and and + calls plus.

function z = implies(x, y)
    z = ~x|y;

function z = iff(x, y)
    z = x&y | ~x&~y;

如有必要,我很乐意超载logical.

I'm happy to overload logical if necessary.

推荐答案

由于有多个线程,如

There is no way to define new Operators in MATLAB as several threads like this one suggest. However, if you'd like to overload an existing operator for you own class, here's MATLAB's documentation page, though I'm sure you've already seen it.

这篇关于在MATLAB中定义其他infix运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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