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

36 次查看(过去 30 天)
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?

采纳的回答

dpb
dpb 2017-4-7
编辑:dpb 2017-4-7
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 个评论
Nana Fernandes
Nana Fernandes 2017-4-10
编辑:Nana Fernandes 2017-4-10
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 2017-4-10
"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?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by