필터 지우기
필터 지우기

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

조회 수: 3 (최근 30일)
Zeynab Mousavikhamene
Zeynab Mousavikhamene 2019년 9월 6일
답변: madhan ravi 2019년 9월 6일
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