How can i change this plot to be be in this form

Please, how can i make the 2D plot (attached image -row plot) appear like any of the signal plots(attached image -signal) in the other image. kindly simplify codes, as I am new to MAtlab

Answers (1)

If you'd like to make a subplot,
figure
subplot(4,1,1) % see help subplot
plot(row_data)
title('My row plot')
xlabel('time (ms)')
ylabel('Amplitude (v)')

8 Comments

Thanks for the reply but i want the only final values to plot in a line instead of the vertical form appearing in the row_plot.jpg
Do you mean you want a series of dots where each spike peaks or you just want a diagonal line going through each of the peaks? Your question is very unclear.
a line going through the peaks of the spikes. I didn't know how best to say it in english.
I understand now. However, there's no simple answer without looking at your data and how you created that plot in the first place. Please attached your data or paste the first few dozen values of your data. It would also be helpful to see your code for the spike plot, if available.
m=zeros(10,10,30); n=30;
for k=1:n
t=linspace(0,1.0,n);
m(3,3,k) = t(k);
vector=sum(m);
end
[v]=vector(:,:); %convert the vector into 1D vector
figure(1),plot(v);
title('plot of sum of the rows in the matrix')
Hi Folakemi, There are lots of problems with this code and it doesn't make much sense.
For example, why does 'm' need to be a 3D array? Why is the call to linespace within the k-loop when it doesn't change at all within that loop? Why take the sum over m when all the values in m are zeros except for 1 number?
I have a feeling this code doesn't do what it is intended to do.
That being said, the (x,y) coordinates of the spikes are as follows.
The y coordinates are just the value of 't'. You don't need the loop at all.
The x coordinates as your data currently stands are 3:10:300 but I have a feeling this is meaningless.
To plot a line over the spikes,
n = 30;
t = linspace(0,1.0,n);
plot(3:10:300, t, 'r-o')
it is a 3D matrix because it represents the RGB values of an image and the single value changing is done for simplicity sake. k changes in value for every iteration. The code did not plot the peaks in a straight line though, it only highlighted the peak in red.thanks for the effort
M is a 3D array but the size of each dimension is (10,10,30). An RGB matrix would have 3 columns, not 10.
Here's a plot of your code (in blue) and my code (in red). The only thing I changed in my code was the line style.
It plots the peaks in a straight line.

Sign in to comment.

Asked:

on 23 Jul 2018

Commented:

on 24 Jul 2018

Community Treasure Hunt

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

Start Hunting!