フィルターのクリア

Convert negative values to positive values in the graph

39 ビュー (過去 30 日間)
Edoardo
Edoardo 2023 年 4 月 7 日
コメント済み: the cyclist 2023 年 4 月 8 日
I have this graph:
The question is, can I convert those negative values to positive? I mean, so that all those spikes in the graph will go upwards instead of go downwards. I mean it will go something like this:
Thank you.

採用された回答

the cyclist
the cyclist 2023 年 4 月 7 日
Yes, but the answer depends on what exactly you have. Do you have
  • just the image
  • the MATLAB figure file, but not the underlying data that made the plot
  • the underlying data
If you have the underlying data, just use abs to take the absolute value of the variable on the y axis, and re-plot.
  4 件のコメント
Edoardo
Edoardo 2023 年 4 月 8 日
Maybe I will use this as an example: Read EDF File
tt = edfread('example.edf');
info = edfinfo('example.edf');
fs = info.NumSamples/seconds(info.DataRecordDuration);
recnum = 5;
signum = 2;
t = (0:info.NumSamples(signum)-1)/fs(signum);
y = tt.(signum){recnum};
plot(t,y)
the cyclist
the cyclist 2023 年 4 月 8 日
If all you want to do is for your negative values to be positive, then abs() obviously does the job.
tt = edfread('example.edf');
info = edfinfo('example.edf');
fs = info.NumSamples/seconds(info.DataRecordDuration);
recnum = 5;
signum = 2;
t = (0:info.NumSamples(signum)-1)/fs(signum);
y = tt.(signum){recnum};
plot(t,abs(y)) % All I did was add abs() here
But as @埃博拉酱 has said, the correct solution really depends on the meaning of the negative values.

サインインしてコメントする。

その他の回答 (1 件)

埃博拉酱
埃博拉酱 2023 年 4 月 8 日
編集済み: 埃博拉酱 2023 年 4 月 8 日
It depends on the meaning of negative values and how they are generated.
From your graph, your data appears to be oscillating with a mean of 0, which may be due to normalization. In this case, negative values make sense, and it is recommended to use a method similar to Data-min(Data(:)) so that the minimum value becomes 0.
If you want to calculate a statistic that is not possible to be negative by definition, such as power, you should usually square the data.
If you are very sure that negative values are meaningless error values, it is recommended to use interpolation to change negative values to the average of positive values on both sides.
I can't quite agree with @the cyclist. When dealing with natural measurements like EEG, it rarely makes sense to use abs because it is continuous but non-differentiable at zero, a feature that is too weird in the macroscopic physical world.

カテゴリ

Help Center および File ExchangeBiomedical Signal Processing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by