How can I solve this error?
15 次查看(过去 30 天)
显示 更早的评论
- I was designing a C program that calculates FS partial-sum approximation but getting this error. How can i solve this?*
Warning: Imaginary parts of complex X and/or Y arguments ignored
Error using axis>LocSetLimits (line 308)
Vector must have 4, 6, or 8 elements.
Error in axis (line 101)
LocSetLimits(ax(j),cur_arg,names);
Code that I used is looks like below:
>>k = 1:1:99;
>>t = linspace(-0.5,0.5,400);
>>B = zeros(1,100);
>>B(1) = 0; % for k=0
>>B(2:1:100) = 8*sin(k*pi/2).*exp(1i*pi*k/2)./(1i*(pi*k).^2);
>>xJhat(1,:) = B(1)*cos(0*2*pi*t);
>>for k = 2:1:100
Bcos(k,:) = B(k)*cos((k-1)*2*pi*t);
xJhat(k,:) = xJhat(k-1,:)+B(k)*cos((k-1)*2*pi*t);
end
>>j = [1 3 7 29 99]+1;
>>for i = 1:1:5
subplot(5,2,2*i-1);plot(t,Bcos(j(i),:));
ylabel(['B[' num2str(j(i)-1) ']cos(' num2str(j(i)-1) '\omega_0n)']);
xlabel('n');axis([-0.5 0.5-1 1]);
subplot(5,2,2*i);plot(t,xJhat(j(i),:));
ylabel(['x' num2str(j(i)-1) '(t)']);
xlabel('n');
end
0 个评论
回答(1 个)
Walter Roberson
2017-5-28
You have
axis([-0.5 0.5-1 1])
and you probably intended
axis([-0.5 0.5 -1 1])
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!