is that code matching the requirements of the problem or not ?
1 次查看(过去 30 天)
显示 更早的评论
```
% Define the function g[n]
n = -4:5;
g = [-3 -3 2 2 0 0 0 -3 -3 -3];
% Plot g[n]
subplot(2,2,1);
stem(n, g);
title('g[n]');
xlabel('n');
ylabel('g[n]');
% Plot the even part of g[n]
ge = g;
subplot(2,2,2);
stem(n, ge);
title('Even part of g[n]');
xlabel('n');
ylabel('ge[n]');
% Plot the odd part of g[n]
go = zeros(size(g));
subplot(2,2,3);
stem(n, go);
title('Odd part of g[n]');
xlabel('n');
ylabel('go[n]');
% Plot g[2n]
n2 = -2:2;
g2n = [2 0 0 -3 -3];
subplot(2,2,4);
stem(n2, g2n);
title('g[2n]');
xlabel('n');
ylabel('g[2n]');
% Plot g[n/2]
n2 = linspace(12,22,3);
gn2 = [-3 -3 -3];
subplot(2,2,4); hold on;
stem(n2, gn2);
title('g[n/2]');
xlabel('n');
ylabel('g[n/2]');
```
0 个评论
回答(1 个)
Walter Roberson
2023-4-27
No. The function is defined over real values but your code is only over integers.
3 个评论
Walter Roberson
2023-4-27
No. What part of your code would be able to calculate the output for n = sqrt(5) for example?
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!