I'm doing an engineering practice report and I need to remove arbitrary data from 2 arrays used in a plot.

조회 수: 1(최근 30일)
Genaro Zambrano
Genaro Zambrano 2020년 2월 14일
댓글: Genaro Zambrano 2020년 2월 14일
How do I take the values from the x axis that are less than zero and remove those elements along with the corresponding elements on the y axis from the arrays?

채택된 답변

Bhaskar R
Bhaskar R 2020년 2월 14일
Suppose data is like
x= -2:0.1:2; % x axis
y = 1:41; % ydata
z = plot(x, y); % Plot x,y to variable z
x_data_ls_0 = z.XData(z.XData<0); % property XData to get the x axis data
ind = find(z.XData<0) ;% grt the indices of the x axes data
z.YData(ind) = []; % remove corresponding y data
z.XData(ind) = []; % remove corresponding x data

추가 답변(0개)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by