how to generate a sine wave with my data in excel sheet?

21 views (last 30 days)
the values in the excel sheet are voltage and phase values with voltage being from column A to N and phase values are from column O to AB. I want to plot a sin wave with x axis as voltage and y axis as phase and also a sine wave with x axis as time and y axis as voltage. How can i do this?

Accepted Answer

dpb
dpb on 7 Apr 2017
Edited: dpb on 7 Apr 2017
Why did you not put the data on either two rows or in two columns; seems far more logical structure.
Still, no problem; just read the file with xlsread and reshape to get the x,y values (I didn't compute, I presume that is an even number of points each in the total; if not you'll have to adjust where the break is and even-up the two series)...
data=xlsread('yourExcelFile');
data=reshape(data,length(data)/2,[]); % make two columns from one vector: see caveats above
plot(data(:,1),data(:,2)) % phase vs amplitude
Now you need to know sampling time to compute the time vector against which to plot....
Fsamp=YourSamplingFrequency;
t=[0:length(data)-1]/Fsamp; % time vector
figure
plot(t,data(:,1)) % amplitude vs time
Label and prettify as desired...
  16 Comments
Nana Fernandes
Nana Fernandes on 10 Apr 2017
Edited: Nana Fernandes on 10 Apr 2017
i know this might seem like a dumb question but how can i make the other elements 14 element long? Should i input more values for frequency and w ? if yes then how so? i feel i might have to give it like a range eg
f= 60:100;
is this right?
btw the values in the excel sheet are voltage and phase values only
dpb
dpb on 10 Apr 2017
"t how can i make the other elements 14 element long?"
Well, to have a given number of elements, linspace is handy as then you hand off the spacing calculation to it...
f=linspace(60,100,14);
But, to generate a smooth sine (or other) waveform you have to have sufficient sampling rate to have enough samples within the highest frequency content in the signal. This means to have only 14 samples you need to ensure those samples cover only the time span of one or two cycles at most and even that is going to be pretty rough.
What's magic about using only 14 samples? Modern PCs have essentially unlimited memory; why not use some of it to model your waveform in some detail?

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!