Why does not coefficients vector include zero?

4 ビュー (過去 30 日間)
Volkan Yangin
Volkan Yangin 2021 年 1 月 18 日
編集済み: Volkan Yangin 2021 年 1 月 18 日
Hi,
In this code, cf should be [3 2 0], but the output is different. What is the reason of this?
Thanks,
clear all
clc
syms x y z
cf = fliplr(coeffs(x*3 + 2*y, [x y z],'All'))
>>cf =
[3, 0]
[0, 2]

回答 (1 件)

Bjorn Gustavsson
Bjorn Gustavsson 2021 年 1 月 18 日
When I change the polynomial to:
cf = fliplr(coeffs(x*3 + 2*z, [x y z],'All'))
I get a 3-D array for the coefficients, as expected. What you see might be the effect of matlabs reduction of the trailing dimensions. Compare for example with:
size(randn(12,23,1))
I don't know how to solve this for you, unfortunately. Maybe you can add a term with high enough degree in your last variable to avoid that type of reduction and then crop the output for your future manipulations - this seems like a very messy idea.
HTH
  1 件のコメント
Volkan Yangin
Volkan Yangin 2021 年 1 月 18 日
編集済み: Volkan Yangin 2021 年 1 月 18 日
Hi Bjorn, thanks a lot for your suggestion.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by