How to add up all elements of a vector in a 1x1 vector?

4 次查看(过去 30 天)
I have a n-dimensional vector which can obviously vary in length based on the users input. Based on that vector I want to label data points in a plot where the first vector element is the label for the first data point, the second vector element is the label for the second data point and so on. I now have the problem that all elements of my vector get labeled to all points so that the complete vector is shown besides every point. Does anyone know how to convert a vector like a = [ 1 7 333 65 8] into this format: label={'1', '7' , '333', '65', '8'} so that I can simply use the text command to label my points?

采纳的回答

Adam Danz
Adam Danz 2023-7-24
a = [ 1 7 333 65 8];
s = string(a)
s = 1×5 string array
"1" "7" "333" "65" "8"
cs = cellstr(string(a))
cs = 1×5 cell array
{'1'} {'7'} {'333'} {'65'} {'8'}

更多回答(0 个)

类别

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

产品


版本

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by