Read the signal data stored in the file and create a program that displays the waveform

Hi Im new to matlab. Please help me. I want to read the signal data stored in a mat file and create a program that displays the waveform. And I want to display data for a specified particular interval. The signal data is from a sine wave. I have tried to use the load function but I dont know how to use it to plot the graph.

6 Comments

Well, you don't use load to plot the data, but the plot function might be of interest...<plot()>
Thank you so much for your comment @dpb. I didnt use load to plot the data, I use it to read the data file. Then, I use the plot function to plot the data but it doesnt seem to work. On the command window an "error: binary operator '*' not implemented for 'scalar' by 'scalar struct' operations" came out. I dont really understand what it means. Here I attached the programme file. Could you please explain to me what is wrong and what should I do. I really appreciate your help.
From the documenation on load the form you used of assigning the result to a variable
S = load(___) loads data into S, using any of the input arguments in the previous syntax group.
  • If filename is a MAT-file, then S is a structure array.
  • If filename is an ASCII file, then S is a double-precision array
The error about "scalar struct operations" is the clue your variable x is structure, not the array you think it is.
Type
whos x
at the command line and see what it returns.
The fix is to use
load('sec2Harmonics.mat');
which will leave whatever is the variable that was used in the workspace when the .mat file was saved in your workspace.
To see what that was/is use
whos -file sec2Harmonics.mat
Thank you so much @dpb! I have got the sine wave that I want to display. You explained it so well it really helps me a lot. Have a great day.
Moral -- post the actual code and error(s) you get first go 'round -- we only know what we're told; we can't see your terminal from here and so don't know that you did move on to the next step and had an error--all we knew was that you used load and wrote "I have tried to use the load function but I dont know how to use it to plot the graph." which leaves the impression you might have thought somehow MATLAB was to automagically plot something when it was load 'ed.
Thank you @dpb for the tips. I'll post a question along with the details next time.

Sign in to comment.

Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Asked:

on 5 May 2021

Commented:

on 7 May 2021

Community Treasure Hunt

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

Start Hunting!