complex sine graph plotting I need help
이전 댓글 표시
my complex sine graph is 1050 points. I want it to be just 100 points for some other math calculations. here is the function. can someone please fix it for me so that stpFunc is 100 instead of 1050 and still graphs similarly, thanks a ton!
n = 1050;
w = [0:.005:1-0.005]';
w=repmat(w,5,1); %repmat(w,10,1);
w=[zeros(50,1);w];
t=[zeros(50,1)];
for i=1:5 %10
t=[t;i*ones(200,1)];
end
stpFunc = sin(2*pi*w.*t);
complex_sine = stpFunc'
figure; plot(stpFunc,'linewidth',3);
댓글 수: 2
Azzi Abdelmalek
2016년 7월 22일
편집: Azzi Abdelmalek
2016년 7월 22일
Can you explain what your code is doing?
Osita Onyejekwe
2016년 7월 22일
답변 (2개)
Star Strider
2016년 7월 22일
I do not understand everything you are doing. If you want ‘w’ to have a length of 100, use the linspace function:
w = linspace(0, 1, 100);
I cannot follow what you are doing with the rest of your code, so you will have to change it to work with the new ‘w’.
댓글 수: 4
Osita Onyejekwe
2016년 7월 22일
Star Strider
2016년 7월 22일
This interpolates the original to be a length of 100, but even using the 'spline' interpolation method, the undersampling does not reproduce the original look of the function.
n = 1050;
w = [0:.005:1-0.005]';
w=repmat(w,5,1); %repmat(w,10,1);
w=[zeros(50,1);w];
t=[zeros(50,1)];
for i=1:5 %10
t=[t;i*ones(200,1)];
end
stpFunc0 = sin(2*pi*w.*t); % Original ‘stpFunc’
stpFunci = linspace(1, length(stpFunc0), 100); % Interpolation Vector
stpFunc = interp1([1:length(stpFunc0)],stpFunc0,stpFunci,'spline'); % Interpolated ‘stpFunc’
complex_sine = stpFunc';
figure; plot(stpFunc,'linewidth',3);
Osita Onyejekwe
2016년 7월 22일
Star Strider
2016년 7월 22일
My pleasure!
If my Answer solved your problem, please Accept it.
카테고리
도움말 센터 및 File Exchange에서 Spline Postprocessing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!