How to repeat the value of y to have the same length as x?

1 次查看(过去 30 天)
I need to add a text to a plot.
text(x,max(E),'it is inf')
and the length of x can be more than one. so I will get the error because the length of x and y (max(E)) are not matching. I want to form y by repeating max(E) with the size of x. For example if the size of x is 4, then I wan to have y=[max(E),max(E),max(E),max(E)]. What is the shortest way to do it?
I want to avoid for loop as much as possible.

回答(1 个)

madhan ravi
madhan ravi 2019-9-6
y = repmat(max(E),size(x))

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by