How to plot a periodic signal without knowing mathematical equations?

I want to create and plot a periodic signal for a school project but I do not know the mathematical expression, I observed this wave from oscilloscope. The wave is shown in picture roughly it is symmetric about vertical line, the periodicity of wave is 100 Hz and the amplitude is 20 volt peak to peak. I also need to export 1000 data from one cycle of wave. If anyone can help me I will be appreciated, thanks in advanced.

2 Comments

And what is the role of Matlab in this? You want to extract the data from the oscilloscope using the Instrument Control Toolbox?
No I have to create and plot tha graph so that I can get th data set after that I will use tha data set values for testing a circuit .If I get data set it will be very easy for me to test circuit, because the signal I get from scope is not accessible all the time and the data set is an important part of project. I hope that the situation is more clear nor, and if you have any more question please do not hesitate to ask.

Sign in to comment.

 Accepted Answer

Try this:
N = 1; % Define 1 Cycle
t = linspace(0, 0.01*N, 100*N);
v = [(1.11*exp(461*t)-1).*((t>=0) & (t<=0.005)) + (111*(1-exp(-461*t))-110).*((t>=0.005) & (t<=0.01))];
figure
plot(t,v)
grid
N = 10; % Define 10 Cycles
t10 = linspace(0, 0.01*N, 100*N);
v10 = repmat(v, 1, N);
figure
plot(t10, v10)
grid
This was part design and part experimentation.
Experiment with the code to get the result you want.

More Answers (1)

Thank you so much for your time and answer, I hope that I'm not asking too much but I am not so good at Matlab as you might notice and I have to complete the project in a short time. I might need to change the wave as you can see in the picture with red line, i.e mirror image of right bottom part. I noticed that I should change (111*(1-exp(-461*t))-110).*((t>=0.005) & (t<=0.01) part but I could not figured out how, I run some experiment but they were not succesfull, so if anybody can help me in this and also how to export 1000 data point from one cycle I will be very grateful, thanks in advanced.

7 Comments

What's wrong with that? Just change
plot(t10, v10)
to
plot(t10, v10, 'r-', 'LineWidth', 2);
and shift your x so that it crosses at .005 instead of .035 and you've got what you need. Right?
@ozan eren — As always, my pleasure.
Here, ‘v1’ is the original vector you asked for, and ‘v2’ will create the second one you want (with both curves concave upwards):
v1 = [(1.11*exp(461*t)-1).*((t>=0) & (t<=0.005)) + (111*(1-exp(-461*t))-110).*((t>=0.005) & (t<=0.01))];
v2 = [(1.11*exp(461*t)-1).*((t>=0) & (t<=0.005)) + (0.111*(exp(461*t))-11).*((t>=0.005) & (t<=0.01))];
The ‘v2’ vector re-creates the original vector (the part from 0 to 0.005), and just shifts it downwards. They are both the same length, so you can use them in the repmat call to create a series of them, just as with ‘v1’. That part does not change.
@Image Analyst — Thank you.
These 2 vectors are exactly what I need. Thank you so much for your time and kind attitude. Now, I need to figured out how to export data from one cycle I'm working on it for 3 days but I could not succeed yet, maybe I should ask a new question. Once again you were so helpful. Also, image Analyst thank you for your interest
As always, my pleasure.
I am not certain what you intend by ‘export’. One option is to create a function file from my code, then call the function from whatever script you want.
Example
function [t2,v] = WaveForm2(N)
t = linspace(0, 0.01, 100);
v2 = [(1.11*exp(461*t)-1).*((t>=0) & (t<=0.005)) + (0.111*(exp(461*t))-11).*((t>=0.005) & (t<=0.01))];
t2 = linspace(0, 0.01*N, 100*N);
v = repmat(v2, 1, N);
end
then save it as ‘WaveForm2.m’, and call it in any script as:
[t,v] = WaveForm2(N); % ‘N’ Must Be An Integer
Otherwise, you can use the save function to save the original waveform to a .mat file, then load it whenever you want.
NOTE I have not tested the function here. The code has not changed. It should work.
I mean getting 1000 data points, i.e. y axis and x axis coordinates from one cycle, so that when I transfer these data points to excel I should get same graph that your code give me. I run your function code, but when I transer it to excel I get a linear plot as shown in the picture below. To be more clear I want a data set which will give same plot as first code that you give me in picure 2. And you are definitely an angel:)
I figured out how to do it, I juct need to take transpose of v10 vector and transfer it to excel and draw the graph for one cycle, I learned a lot from you once more thanks a lot:)

Sign in to comment.

Products

Release

R2016b

Community Treasure Hunt

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

Start Hunting!