作业帮 > 综合 > 作业

matlab问题 如何设计程序 用matlab实现序列奇偶系列的分解.比如【1 2 3 4 5 6 7 8 9】 分解为

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/02 08:10:58
matlab问题
如何设计程序 用matlab实现序列奇偶系列的分解.比如【1 2 3 4 5 6 7 8 9】 分解为奇数系列【1 3 5 7 9】,偶数系列【2 4 6 8】
a=[1,2,3,4,5,6,7,8,9];a1=a(1:2:length(a));a2=a(2:2:length(a));
再问: 程序 n=0:8; a=[1,2,3,4,5,6,7,8,9]; a1=a(1:2:length(a)); a2=a(2:2:length(a)); stem(n,a1); stem(n,a2); 可是出现以下问题 怎么回事啊 ??? Error using ==> stem The length of X must match the number of rows of Y. Error in ==> Untitled at 5 stem(n,a1);
再答: n的大小应该根据a1的元素个数一致 n1=1:length(a1);n2=1:length(a2); a=[1,2,3,4,5,6,7,8,9]; a1=a(1:2:length(a)); a2=a(2:2:length(a)); stem(n1,a1); stem(n2,a2);
再问: a=[1,2,3,4,5,6,7,8,9]; a1=a(1:2:length(a)); a2=a(2:2:length(a)); n1=1:length(a1);n2=1:length(a2); stem(n1,a1); stem(n2,a2); 这个顺序我换了下就可以了 哈哈哈 谢谢你哈 高手!