了解MATLAB中的冒号表示法 [英] Understanding colon notation in MATLAB

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

问题描述

因此,我对MATLAB完全陌生,并且试图了解数学运算中的冒号表示法.因此,在本书中,我发现了这一说法:

So I'm completely new to MATLAB and I'm trying to understand colon notation within mathematical operations. So, in this book I found this statement:

w(1:5)=j(1:5) + k(1:5);

我不明白它的真正作用.我知道w(1:5)几乎遍历了从索引1到5的w数组,但是在上面的语句中,w的所有索引最后不应该等于j(5) + k(5)吗?还是我完全错了这是怎么回事?如果有人在Java中发布与该版本相当的代码,那将是非常棒的.在此先感谢:-)

I do not understand what it really does. I know that w(1:5) is pretty much iterating through the w array from index 1 through 5, but in the statement above, shouldn't all indexes of w be equal to j(5) + k(5) in the end? Or am I completely wrong on how this works? It'd be awesome if someone posted the equivalent in Java to that up there. Thanks in advance :-)

推荐答案

我很确定这意味着

"w的前5个元素应是j的前5个元素+ k的前5个元素"(我不确定matlab数组是否以0或1开头)

"The first 5 elements of w shall be the first 5 elements of j + the first 5 elements of k" (I am not sure if matlab arrays start with 0 or 1 though)

所以:

w1 = j1+k1
w2 = j2+k2
w3 = j3+k3
w4 = j4+k4
w5 = j5+k5

在这里考虑向量加法".

Think "Vector addition" here.

这篇关于了解MATLAB中的冒号表示法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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