How to show an ordered polynomial independently of the value of the coefficients? guide

조회 수: 1 (최근 30일)
What happens is that I have the idea that the user can insert the following values (it is random): 50 20 60 1000 2000 400 then my program will print 50x ^ 5 + 20x ^ 4 + 60x ^ 3 + 1000x ^ 2 + 2000x + 400 I mean that I want that independently of the value of the coefficients my program prints in that order ax ^ 5 + bx ^ 4 + cx ^ 3 + dx ^ 2 + ex + f in this case it would be a = 50 b = 20 c = 60 d = 1000 e = 2000 f = 400 I would like the value of these coefficients not to matter but to show it in that order, is it possible?
  댓글 수: 1
Jan
Jan 2017년 11월 9일
What are your inputs? Do you have a vector or 6 different variables? Where do you want to "print"? What have your tried and what is the actual problem?

댓글을 달려면 로그인하십시오.

답변 (1개)

Jan
Jan 2017년 11월 9일
편집: Jan 2017년 11월 9일
x = [50 20 60 1000 2000 400];
n = length(x);
fprintf('%gx^%d + ', [x(1:n-1); n-1:-1:1]);
fprintf('%g\n', x(n));

카테고리

Help CenterFile Exchange에서 Function Creation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by