使用转与MATLAB中ctranspose [英] Using transpose versus ctranspose in MATLAB

查看:526
本文介绍了使用转与MATLAB中ctranspose的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当移调矢量/在MATLAB矩阵,我见过和使用在 (apostropohe)算很长一段时间。

When transposing vectors/matrices in MATLAB, I've seen and used just the ' (apostropohe) operator for a long time.

例如:

>> v = [ 1 2 3 ]'

v = 

    1
    2
    3

不过,这是在共轭转置因为我最近发现,或 ctranspose

这似乎只当有涉及复数,在这里,如果你想矩阵转置没有得到共轭事情,你需要使用 opertator。

This seems to only matter when there are complex numbers involved, where if you want to transpose a matrix without getting the conjugate, you need to use the .' opertator.

它是很好的做法,还使用了真正的矩阵和向量呢?我们应该怎样教初学者MATLAB?

Is it good practice to also use the .' for real matrices and vectors then? What should we be teaching MATLAB beginners?

推荐答案

有趣的问题!

我肯定会说这是用很好的做法。当你只是想转,即使这些数字是真实的,从而 将有同样的效果。电源方面的原因是:

I would definitely say it's good practice to use .' when you just want to transpose, even if the numbers are real and thus ' would have the same effect. The mains reasons for this are:


  1. 概念清晰:如果你需要调换,调换只。不要在不必要的共轭扔。这是不好的做法。你会习惯编写 来转,将无法发现其中的差别。有一天,你会写 应使用。由于这种可能的图示,请参阅这个问题或<一个href=\"http://stackoverflow.com/questions/23509241/whats-the-difference-between-two-way-to-input-matlab-complex-matrices\">this 之一。

  1. Conceptual clarity: if you need to transpose, just transpose. Don't throw in an unnecessary conjugation. It's bad practice. You'll get used to writing ' to transpose and will fail to notice the difference. One day you will write ' when .' should be used. As probable illustrations of this, see this question or this one.

未来的proofness 。如果有一天,在未来的你申请你的功能到复杂的输入行为会突然改变,你将有一个很难找到的原因。相信我,我知道我说的 1

Future-proofness. If one day in the future you apply your function to complex inputs the behaviour will suddenly change, and you will have a hard time finding the cause. Believe me, I know what I say1.

当然,如果你使用的是真正的输入,但一个结合才有意义复杂的输入,就使用 。例如,如果您要为真正的向量的点积,可以适当使用 ,因为如果你想在未来使用复杂的输入,共轭转会更有意义

Of course, if you are using real inputs but a conjugation would make sense for complex inputs, do use '. For example, if you are defining a dot product for real vectors, it may be appropriate to use ', because should you want to use complex inputs in the future, the conjugate transpose would make more sense.

1 在我早期的Matlab的日子里,我花了很长一段时间在我的code,这竟然用<$ C引起的追溯某个问题$ C> 时,我应该已经使用。真正让我心烦,它是我的教授,谁实际上说, 意味着转!他忘了提共轭,因此我的错误。教训我了解到:不是 ;教授可以告诉你的东西都是完全错误的:-)

1 In my early Matlab days, it took me quite a while to trace back a certain problem in my code, which turned out to be caused by using ' when I should have used .'. What really got me upset is, it was my professor who had actually said that ' meant transpose! He forgot to mention the conjugate, and hence my error. Lessons I learned: ' is not .'; and professors can tell you things that are plain wrong :-)

这篇关于使用转与MATLAB中ctranspose的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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