フィルターのクリア

Can I get help with loops and char function?

1 回表示 (過去 30 日間)
Amy Joyce Valencia
Amy Joyce Valencia 2021 年 10 月 23 日
コメント済み: Chunru 2021 年 10 月 23 日
Write a script that accepts as input a number n greater than or equal to 1 and less than 8, and then uses this number to calculate the 1st, 2nd, 3rd, ..., nth derivative of the polynomial below. The output should be formatted as below (in this example, the user gave an input of 5). Hint: Use the char() function to convert any symbolic variable, expression or equation into a string.
2𝑥^9 +3𝑥^6 −8𝑥^2
n = input('Enter # of derivatives to compute (1-7): '); %prompts a value input
syms x
E = 2*x^9 + 3*x^6 - 8*x^2
diff(E, n)
This is what I have so far. I have no idea how to use the char function

回答 (1 件)

Chunru
Chunru 2021 年 10 月 23 日
編集済み: Chunru 2021 年 10 月 23 日
n = 3; %input('Enter # of derivatives to compute (1-7): '); %prompts a value input
syms x
E = 2*x^9 + 3*x^6 - 8*x^2
E = 
for i=1:n
a = diff(E, i)
c =char(a);
disp(c)
end
a = 
18*x^5 - 16*x + 18*x^8
a = 
90*x^4 + 144*x^7 - 16
a = 
360*x^3 + 1008*x^6
  2 件のコメント
Amy Joyce Valencia
Amy Joyce Valencia 2021 年 10 月 23 日
How would I show all the prior derivatives? For example, if n=3 how would I show the first and second derivative as well
Chunru
Chunru 2021 年 10 月 23 日
See above.

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

カテゴリ

Help Center および File ExchangeFormula Manipulation and Simplification についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by