フィルターのクリア

How can I keep row from index number

2 ビュー (過去 30 日間)
Phudit Kanittasut
Phudit Kanittasut 2021 年 5 月 1 日
回答済み: Image Analyst 2021 年 5 月 1 日
clear
Data = readmatrix('Pure Brain Spectra.csv');
rows=length(Data)
cols=width(Data)
for i = 2:cols
Xlocs = Data(:,1);
Ylocs = Data(:,i);
select = [Xlocs Ylocs];
[value,index1] = findpeaks(select(:,i));
end
How can I keep the row in data with Index number from matix index1
  2 件のコメント
Image Analyst
Image Analyst 2021 年 5 月 1 日
編集済み: Image Analyst 2021 年 5 月 1 日
You forgot to attach 'Pure Brain Spectra.csv' again. I'll check back later for it.
Phudit Kanittasut
Phudit Kanittasut 2021 年 5 月 1 日
Thx for your advice

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

回答 (1 件)

Image Analyst
Image Analyst 2021 年 5 月 1 日
There were so many errors in your code that I can't explain them all. All I'm going to do is show you how it's done.
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 18;
Data = readmatrix('Pure Brain Spectra.csv');
whos Data
[rows, columns] = size(Data)
Xlocs = Data(:, 1);
for col = 2 : columns
thisColumnY = Data(:, col);
nexttile;
plot(Xlocs, Data(:, col), 'b-');
[peakValues, indexesOfPeaks] = findpeaks(thisColumnY, 'Threshold', 1000);
grid on;
hold on
plot(Xlocs(indexesOfPeaks), peakValues, 'rv', 'LineWidth', 2, 'MarkerSize', 7);
caption = sprintf('Column %d', col);
title(caption, 'FontSize', fontSize);
drawnow;
end
hold off;
g = gcf;
g.WindowState = 'maximized'
fprintf('Done running %s.m ...\n', mfilename);
but you should really take time to understand all the options for findpeaks() because I'm not sure what you consider to be a peak or not and there are just too many of them identified if you simply go with the defaults.

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by