MATLAB Answers

how to plot multiple waves on one surface

23 views (last 30 days)
Samaneh Arzpeima
Samaneh Arzpeima on 15 Apr 2019
Edited: Samaneh Arzpeima on 19 Apr 2019
I have an inclined surface and 20 different specified points(x,y,z) on it.for each station I have a set of (time, amplitude) data i.e. a wave. I need to plot each wave at each related point. so a surface with 20 waves on it.
I have no idea how to do it, subplot probably won't work because I need to plot on specified points.
please help!


Show 9 older comments
Samaneh Arzpeima
Samaneh Arzpeima on 19 Apr 2019
Thank you all
I guess I couldn't explain myself cleary,let me add a schematic illustration of what I want to have eventually.
3D would be very complicated,so a 2D surface with waves on it
stations are the seismographs that I have in a vast area and the .dat files are the data that I got from each station. I need to visualize those data and see the different behavior in space and time.
thank you again for you time,and really need your help
Samaneh Arzpeima
Samaneh Arzpeima on 19 Apr 2019
the real format is "str-10dep00.dat"
but it seems that I can not attach files with .dat extension so I save it as .txt
Samaneh Arzpeima
Samaneh Arzpeima on 19 Apr 2019
@Etsuo Maeda Thank you.Wow! moving sations? ! I am not sure if I could catch what you've done.

Sign in to comment.

Answers (1)

David Wilson
David Wilson on 19 Apr 2019
Here is a mock up solution.
Code is: below. I've used part of your data, but I've made up some similar data (using a sinc function) for the other trends. I've also edited your data file and stripped the header comments.
%% plot mini plots
fname = 'str-10dep00.dat';
fid = fopen(fname);
A = fscanf(fid,'%f');
A = reshape(A, 8,length(A)/8)';
t = A(:,1);
Now I've made a grid plot, and plotted the trends in row order. You will read each from a different file of course.
%% generate some interesting data
%% Now try grid
y = 2*[0:4]; z = 2*[0:-1:-5];
[Y,Z] = meshgrid(y,z);
dum = sinc(t/10);
D = [A(:,2:end), dum.*randn(length(t),23)*0.1] % store in row order
plot(Y,Z,'bo','MarkerFaceColor',[0.4588 0.7333 0.9922]);
xlabel('x'); ylabel('z')
hold on
for k=1:size(D,2)
s = D(:,k);
i = mod(k-1,5)+1;
j = -floor((k-1)/5);
x = (2*i-2)+t/t(end);
y = 2*j+ s/range(s);
plot(x,y,'-','color',[0.3176 0.6157 0.6863])
hold off


Samaneh Arzpeima
Samaneh Arzpeima on 19 Apr 2019
Thank You
The figure is almost what I need.
just a few questions
1.after running the " plot mini plots " in a folder that I have all my .dat files ,I have got no value for A and t, just [ ]
2.I don't have toolbox for sinc function
can I replace it with sinct = @(t) sin(pi*t+1E-8)./(pi*x + 1E-8);
Samaneh Arzpeima
Samaneh Arzpeima on 19 Apr 2019
@David Wilson
Hello again
for the "plot mini plots " part in your code, I changed it.
with the code in bellow, I did read all the .dat file and got a matrix(=Fault) with a 3000*8*30 size.
t=Fault(:,1,i) and the amplitude of each wave is Fault(:,3,i)
idir = './Site/'; %directory containing the all .dat file
% This Fault matrix contains all the data of all site.dat files
Fault = [];
% read all the dat files
files = dir([idir,'*.dat']);
% read the Fault_Station.txt file to get the coordinate
filename = 'FAULT_STATIONS.txt';
[Fault_Cor] = importdata(filename);
% number of rows in one site*.dat file
Number_of_rows = 30021;
for i = 1:numel(files)
file_name = [cell2mat(Fault_Cor.textdata(i,4)) '.dat'];
T = importfile1(file_name, 22,Number_of_rows );
Fault(:,:,i) = table2array(T);
t = [];
y = [];
for i = 1:size(Fault,3)
t1 = Fault(:,1,i); % 3000*1 double
y1 = Fault(:,3,i); % 3000*1 double
t = [t; t1]; % 90000*1 double
y = [y; y1]; % 90000*1 double
now I am totally lost!
don know what to do next, I am not sure if I understood your sinc/dum or D. Maybe you cut the header in D...

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!