Obtain the Waviness of Graph

조회 수: 2 (최근 30일)
Ang Xian Jia
Ang Xian Jia 2019년 11월 17일
댓글: Ang Xian Jia 2019년 11월 23일
I would like to superimpose the two graphs into one graph by making sure that the peaks of both graphs are at the same point. (Note that each graph has exactly three peaks - highest points) In other words, the superimposed graph must also have only 3 peaks, which are the peaks of graph 1 and also graph 2. During the process, strecthing or shrinking of the graph can be done. The reason of all this is to obtain the graphical demonstration of waviness of second graph. Is there a way to do that?
Attached above is the first graph data and second graph data. The y variable for both graphs is y_graph and x variable for both graphs is x in the mat file.
Below is graph 1.
Below is graph 2.
  댓글 수: 2
Akira Agata
Akira Agata 2019년 11월 18일
If possible, could you upload your data as .mat file?
Ang Xian Jia
Ang Xian Jia 2019년 11월 19일
Mat file is uploaded and Question is updated.

댓글을 달려면 로그인하십시오.

답변 (1개)

Philippe Lebel
Philippe Lebel 2019년 11월 19일
편집: Philippe Lebel 2019년 11월 19일
Does this help you get what you wnat (didn t have the time to finish with the loading ond plotting of data 1)
here is the code (just change max_x_plot_1 for the actual lenght of the plot_1 (didn't load graph1 data))
[max_1,index_1] = max(y_graph);
spacing = floor(length(y_graph)/3);
for i = 1:3
offsets(i) = (i-1)*spacing;
[maxes(i), indexes(i)] = max(y_graph((i-1)*spacing + 1:(i*spacing)));
end
indexes = indexes + offsets;
y_graph_trunc = y_graph(indexes(1):indexes(3));
max_x_plot_1 = 2.3*10^4;
ratio = max_x_plot_1 / length(y_graph_trunc);
new_x = 1:ratio:max_x_plot_1;
plot(new_x,y_graph_trunc)
  댓글 수: 4
Philippe Lebel
Philippe Lebel 2019년 11월 19일
편집: Philippe Lebel 2019년 11월 19일
how about that:
close all
clear
load('firstgraph_y_graph.mat')
load('firstgraph_x_graph.mat')
plot(x, y_graph);
hold on
max_first_graph_y = max(y_graph);
max_first_graph_x = max(x);
load('secondgraphdata.mat')
[max_1,index_1] = max(y_graph);
spacing = floor(length(y_graph)/3);
for i = 1:3
offsets(i) = (i-1)*spacing;
[maxes(i), indexes(i)] = max(y_graph((i-1)*spacing + 1:(i*spacing)));
end
indexes = indexes + offsets;
y_graph_trunc = y_graph(indexes(1):indexes(3));
ratio = max_first_graph_x / length(y_graph_trunc);
new_x = 1:ratio:max_first_graph_x;
y_offset = min(y_graph_trunc);
y_graph_trunc = y_graph_trunc - y_offset;
y_graph_trunc = y_graph_trunc * max_first_graph_y / max(y_graph_trunc);
plot(new_x,y_graph_trunc)
Ang Xian Jia
Ang Xian Jia 2019년 11월 23일
Hi Phillipee,
Is it possible to match those 3 peaks together also ?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by