【MATLAB】plot 표시 시간 단축을 위해 데이터를 씨닝한다
14517 단어 matlab
소개
빌어 먹을 데이터 1를 plot
에 전달하면 표시하는 데 상당한 시간이 걸립니다.
음악 데이터라면 1곡당 5분 정도 정도이므로 뭐 뭐지만, 업무로 취급하는 데이터라면 샘플링 주파수가 $200\rm{[kHz]}$로 길이가 몇 시간 단위이거나 해서 그렇게 무겁다.
해결책의 하나로서, 데이터를 미리 잡아 당겨 데이터 사이즈를 삭감하고 나서 plot
에 건네주는 처리가 생각된다.
이번에는 우선 matlab
표준 함수를 사용하여 목적을 달성 할 수 있는지 검토하고, 다음에 씨닝 처리를 손 실장 (바퀴의 재발명)하여 결과를 확인한다.
matlab 표준 함수 (decimate)
씨닝 처리라고하면 Signal Processing ToolBox
에는 decimate
라는 함수가 있습니다.
씨닝 — 정수 계수 단위로 샘플 속도 감소
% 信号を生成
Fs = 44100;
T = 10;
N = Fs * T;
t = ((1:N)-1)/Fs;
y = 0.1 * rand(1, N);
y = y - mean(y);
% 1s及び5sにトランジェント成分がある信号
y(Fs:Fs+100) = 1;
y(Fs*5:Fs*5+100) = -0.5;
subplot 211
plot(t, y);
str = sprintf('Original Data(N=%d)', length(y));
title(str);
grid on
ylim([-1 1]);
xlabel('t[s]');
decimation = 100;% 間引き量
y2 = decimate(y,decimation);
t2 = ((1:length(y2))-1)/Fs*decimation;
subplot 212
plot(t2, y2);
str = sprintf('Decimated Data(N=%d)', length(y2));
title(str);
grid on
ylim([-1 1]);
xlabel('t[s]');
decimate 결과

원래 데이터와 decimate
후 데이터를 비교하면 데이터 수가 줄어들지 만 대부분의 모양이 바뀝니다. $ 1\rm {[s]} $ 및 $ 5\rm {[s]} $에있는 과도 성분의 진폭은 작다. 이번 용도에는 조금 맞지 않았던 느낌.
씨닝 처리를 손 실장
보고 싶은 것은 신호의 최대치와 최소치이므로, 그것을 추출하는 처리를 만든다.
그림으로 하면 이런 느낌. 슬라이드 창의 최대 값과 최소값을 추출합니다.

이런 처리는 무엇인가 명칭이 있나요?
어쩌면 세상에 있는 다양한 묘화 처리는 이것을 하고 있다고 생각하지만…
구현
DecimationProcfunction y = DecimationProc(x, r)
r2 = r * 2;
% length(x)がr2の倍数となるようにxをゼロパディング
mod1 = mod(length(x), r2);
if(mod1 == 0)
x2 = x;
else
x2 = [x; zeros(r2 - mod1, 1)];
end
% N行1列の行列を、r2行(N/r2)列の行列に変換(max, min処理のため)
x2 = reshape(x2, [r2, length(x2)/r2]);
% 各列のmax/minを求めて、1行(N/r2)列のmax/min行列を取得
[x2_max, x2_max_ind] = max(x2);
[x2_min, x2_min_ind] = min(x2);
% 各列のmaxとminを順番を整列してyに格納
y = zeros(ceil(length(x)/r2), 1);
for n = 1:length(x2_max)
if(x2_max_ind(n) > x2_min_ind(n))
y(2 * n - 1) = x2_min(n);
y(2 * n) = x2_max(n);
else
y(2 * n - 1) = x2_max(n);
y(2 * n) = x2_min(n);
end
end
% r点から1点選ぶのではなく,2*r点から2点選ぶという処理になっているため,yは2*rの倍数となってしまう
% それを補正する処理
n1 = (ceil(length(x)/r));
if(length(y) > n1)
y = y(1:n1);
end
end
전체적으로 더러워서 멀티 채널 등에는 대응하지 않기 때문에 개량의 여지가 너무 크다.for
문장 처리 또는 더 많은 matlab
틱한 쓰기가있을 것 같지만 잘 모르겠다. (요와요와 프로그래머)
왠지 움직이고 있기 때문에 요시!
결과
손으로 구현 된 씨닝 처리를 사용하여 처리 한 결과를 그래프에 그립니다.
decimatedData = DecimationProc(y, decimation);
subplot 313
t3 = ((1:length(decimatedData))-1)*decimation/Fs;
plot(t3, decimatedData);
grid on
ylim([-1 1]);
str = sprintf('Decimated Data2(N=%d)', length(decimatedData));
title(str);
xlabel('t[s]');

원래와 파형의 외형이 일치했습니다.
결과 2 (확대)
1 [s] 부근을 확대하여 stem
함수로 그래프를 그려 보자.

결과 3 (음악 데이터)
자유 음원을 읽고 비슷한 방식으로 솟아나 갔다.

이쪽도 좋은 느낌으로 표시 할 수있다.
htps // // 논 d. 글쎄. jp/20200611125508 ↩
Reference
이 문제에 관하여(【MATLAB】plot 표시 시간 단축을 위해 데이터를 씨닝한다), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/dokagui_tairan/items/3851f702573ab4bac8aa
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
씨닝 처리라고하면
Signal Processing ToolBox
에는 decimate
라는 함수가 있습니다.씨닝 — 정수 계수 단위로 샘플 속도 감소
% 信号を生成
Fs = 44100;
T = 10;
N = Fs * T;
t = ((1:N)-1)/Fs;
y = 0.1 * rand(1, N);
y = y - mean(y);
% 1s及び5sにトランジェント成分がある信号
y(Fs:Fs+100) = 1;
y(Fs*5:Fs*5+100) = -0.5;
subplot 211
plot(t, y);
str = sprintf('Original Data(N=%d)', length(y));
title(str);
grid on
ylim([-1 1]);
xlabel('t[s]');
decimation = 100;% 間引き量
y2 = decimate(y,decimation);
t2 = ((1:length(y2))-1)/Fs*decimation;
subplot 212
plot(t2, y2);
str = sprintf('Decimated Data(N=%d)', length(y2));
title(str);
grid on
ylim([-1 1]);
xlabel('t[s]');
decimate 결과

원래 데이터와
decimate
후 데이터를 비교하면 데이터 수가 줄어들지 만 대부분의 모양이 바뀝니다. $ 1\rm {[s]} $ 및 $ 5\rm {[s]} $에있는 과도 성분의 진폭은 작다. 이번 용도에는 조금 맞지 않았던 느낌.씨닝 처리를 손 실장
보고 싶은 것은 신호의 최대치와 최소치이므로, 그것을 추출하는 처리를 만든다.
그림으로 하면 이런 느낌. 슬라이드 창의 최대 값과 최소값을 추출합니다.

이런 처리는 무엇인가 명칭이 있나요?
어쩌면 세상에 있는 다양한 묘화 처리는 이것을 하고 있다고 생각하지만…
구현
DecimationProcfunction y = DecimationProc(x, r)
r2 = r * 2;
% length(x)がr2の倍数となるようにxをゼロパディング
mod1 = mod(length(x), r2);
if(mod1 == 0)
x2 = x;
else
x2 = [x; zeros(r2 - mod1, 1)];
end
% N行1列の行列を、r2行(N/r2)列の行列に変換(max, min処理のため)
x2 = reshape(x2, [r2, length(x2)/r2]);
% 各列のmax/minを求めて、1行(N/r2)列のmax/min行列を取得
[x2_max, x2_max_ind] = max(x2);
[x2_min, x2_min_ind] = min(x2);
% 各列のmaxとminを順番を整列してyに格納
y = zeros(ceil(length(x)/r2), 1);
for n = 1:length(x2_max)
if(x2_max_ind(n) > x2_min_ind(n))
y(2 * n - 1) = x2_min(n);
y(2 * n) = x2_max(n);
else
y(2 * n - 1) = x2_max(n);
y(2 * n) = x2_min(n);
end
end
% r点から1点選ぶのではなく,2*r点から2点選ぶという処理になっているため,yは2*rの倍数となってしまう
% それを補正する処理
n1 = (ceil(length(x)/r));
if(length(y) > n1)
y = y(1:n1);
end
end
전체적으로 더러워서 멀티 채널 등에는 대응하지 않기 때문에 개량의 여지가 너무 크다.for
문장 처리 또는 더 많은 matlab
틱한 쓰기가있을 것 같지만 잘 모르겠다. (요와요와 프로그래머)
왠지 움직이고 있기 때문에 요시!
결과
손으로 구현 된 씨닝 처리를 사용하여 처리 한 결과를 그래프에 그립니다.
decimatedData = DecimationProc(y, decimation);
subplot 313
t3 = ((1:length(decimatedData))-1)*decimation/Fs;
plot(t3, decimatedData);
grid on
ylim([-1 1]);
str = sprintf('Decimated Data2(N=%d)', length(decimatedData));
title(str);
xlabel('t[s]');

원래와 파형의 외형이 일치했습니다.
결과 2 (확대)
1 [s] 부근을 확대하여 stem
함수로 그래프를 그려 보자.

결과 3 (음악 데이터)
자유 음원을 읽고 비슷한 방식으로 솟아나 갔다.

이쪽도 좋은 느낌으로 표시 할 수있다.
htps // // 논 d. 글쎄. jp/20200611125508 ↩
Reference
이 문제에 관하여(【MATLAB】plot 표시 시간 단축을 위해 데이터를 씨닝한다), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/dokagui_tairan/items/3851f702573ab4bac8aa
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
function y = DecimationProc(x, r)
r2 = r * 2;
% length(x)がr2の倍数となるようにxをゼロパディング
mod1 = mod(length(x), r2);
if(mod1 == 0)
x2 = x;
else
x2 = [x; zeros(r2 - mod1, 1)];
end
% N行1列の行列を、r2行(N/r2)列の行列に変換(max, min処理のため)
x2 = reshape(x2, [r2, length(x2)/r2]);
% 各列のmax/minを求めて、1行(N/r2)列のmax/min行列を取得
[x2_max, x2_max_ind] = max(x2);
[x2_min, x2_min_ind] = min(x2);
% 各列のmaxとminを順番を整列してyに格納
y = zeros(ceil(length(x)/r2), 1);
for n = 1:length(x2_max)
if(x2_max_ind(n) > x2_min_ind(n))
y(2 * n - 1) = x2_min(n);
y(2 * n) = x2_max(n);
else
y(2 * n - 1) = x2_max(n);
y(2 * n) = x2_min(n);
end
end
% r点から1点選ぶのではなく,2*r点から2点選ぶという処理になっているため,yは2*rの倍数となってしまう
% それを補正する処理
n1 = (ceil(length(x)/r));
if(length(y) > n1)
y = y(1:n1);
end
end
손으로 구현 된 씨닝 처리를 사용하여 처리 한 결과를 그래프에 그립니다.
decimatedData = DecimationProc(y, decimation);
subplot 313
t3 = ((1:length(decimatedData))-1)*decimation/Fs;
plot(t3, decimatedData);
grid on
ylim([-1 1]);
str = sprintf('Decimated Data2(N=%d)', length(decimatedData));
title(str);
xlabel('t[s]');

원래와 파형의 외형이 일치했습니다.
결과 2 (확대)
1 [s] 부근을 확대하여
stem
함수로 그래프를 그려 보자.
결과 3 (음악 데이터)
자유 음원을 읽고 비슷한 방식으로 솟아나 갔다.

이쪽도 좋은 느낌으로 표시 할 수있다.
htps // // 논 d. 글쎄. jp/20200611125508 ↩
Reference
이 문제에 관하여(【MATLAB】plot 표시 시간 단축을 위해 데이터를 씨닝한다), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/dokagui_tairan/items/3851f702573ab4bac8aa텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)