y=((x+5)^3)/(x^2) calculate the value of y for the following values of x using element by element operations: 1,2,3,4,5,6.
clc; clear; close all;
%page 86 problem 2
x = [1:6]
y = ((x+5).^3)/(x.^2)
When I get the answer, it's a single number, and I don't think that should be the case.

 採用された回答

Geoff Hayes
Geoff Hayes 2014 年 9 月 28 日
編集済み: Geoff Hayes 2014 年 9 月 28 日

7 投票

Kraig - if you want the output to be an array, because you want an element-by-element division of the two rows, you need to prefix the division operator with a period
y = ((x+5).^3)./(x.^2)
much like what you are already doing for the exponents of 3 and 2.
Without the period, the code is attempting to solve the system of linear equations yA = B, where (in your case) B is the row vector (x+5).^3 and A is the row vector x.^2. See mrdivide for details.

1 件のコメント

Kraig Orcutt
Kraig Orcutt 2014 年 9 月 28 日
Of course! Thank you!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by