对两个多项式求和 [英] Summing two polynomials

查看:76
本文介绍了对两个多项式求和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个将两个多项式相加的内置Matlab函数.

I'm looking for a built-in Matlab function that sums two polynomial.

示例:

p1(x)和p2(x)在代码标准Matlab向量中表示:

p1(x) and p2(x) are represented in code standard Matlab vectors:

p1 = [500 400 300 200 100 50];
p2 = [3 2 1 5];

如何使用内置的Matlab函数对这两个多项式求和以得出ps(x);无需编写显式的m文件功能?

How do I sum these two polynomials to get ps(x) with using built-in Matlab function(s); without writing an explicit m-file function?

推荐答案

我肯定希望有更好的方法(我可能会将其放入辅助函数中),但这似乎可以正常工作:

I sure hope there is a nicer way of doing it (I'd probably put this into a helper function), but this seems to work just fine:

[zeros(1, size(p1,2)-size(p2,2)) p2] + [zeros(1, size(p2,2)-size(p1,2)) p1]

ans =

   500   400   303   202   101    55

这篇关于对两个多项式求和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆