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 CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by