Adding a value to a vector

2 次查看(过去 30 天)
Chau Chin Haw
Chau Chin Haw 2021-1-16
评论: Jan 2021-1-16
I have vector x
x=[ 1 2 3 ]
I want i add value 4 to every value in x
[ 1 2 3 ] + 4
Expected outcome
x=[ 5 6 7 ]
How can i perform this in matlab?

回答(1 个)

Cris LaPierre
Cris LaPierre 2021-1-16
The same way. What have you tried?
See Ch 6 of MATLAB Onramp.
x=[ 1 2 3 ];
x=x + 4
x = 1×3
5 6 7

类别

Help CenterFile Exchange 中查找有关 Multidimensional Arrays 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by