Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个问题(八度音阶):假设我有 a = 1 2 3 4 5
我想在 a.. 中的每个元素中添加 'b' 字符。这样我就得到了类似的东西:a = 1b 2b 3b 4b 5b
我怎么做?谢谢
为了能够做到这一点,a必须将其定义为字符串而不是双精度数组。可能有一个更优雅的解决方案,但以下工作:
a
a = num2str(1:5); % '1' is a(1), '2' is a(5), etc... % a(2) to a(4) are white spaces for k=2:4:18 a(k) = 'b'; end