remove negative values from one column and the corresponding data in another coloumn

10 Ansichten (letzte 30 Tage)
Please, I have two coloumns of data (time and coresponding strains), I want to remove the negative values of the strains and their correponding time. I extracted the negative values of strain by x=>0. The negative values was removed successifully but the corresponding time were not.
how can I fix it. They should be equal vectors to draw them.
Thanks

Akzeptierte Antwort

Image Analyst
Image Analyst am 12 Mai 2023
Try this:
rowsToDelete = data(:, 1) < 0; % Where values in column 1 are less than 0
data(rowsToDelete, :) = []; % Delete all columns for those rows by setting to null.
% Or alternatively you can do it this way
rowsToKeep = data(:, 1) >= 0; % Where values in column 1 are more than 0
data = data(rowsToKeep, :); % Keep all columns for those rows.

Weitere Antworten (1)

Torsten
Torsten am 12 Mai 2023
Verschoben: Torsten am 12 Mai 2023
t = linspace(0,1);
x = -1+2*rand(size(t));
idx = x<=0;
x(idx) = [];
t(idx) = [];
size(t)
ans = 1×2
1 59
size(x)
ans = 1×2
1 59

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by