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

21 ビュー (過去 30 日間)
Nana Fernandes
Nana Fernandes 2017 年 4 月 7 日
コメント済み: dpb 2017 年 4 月 10 日
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 Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by