i need help with building 2 row 10 colum matrix, the first row will present my x values and under every x i want the matrix to show me the value of f(x)
for example, if my f(x) = 2x and 0<x<11
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
thanks for the help

 採用された回答

KSSV
KSSV 2021 年 1 月 11 日

0 投票

x = linspace(0,11,10) ;
f = 2*x ;
iwant = [x;f]
iwant = 2×10
0 1.2222 2.4444 3.6667 4.8889 6.1111 7.3333 8.5556 9.7778 11.0000 0 2.4444 4.8889 7.3333 9.7778 12.2222 14.6667 17.1111 19.5556 22.0000

4 件のコメント

reshef caspi
reshef caspi 2021 年 1 月 11 日
thank you very match!
reshef caspi
reshef caspi 2021 年 1 月 11 日
hi again, what if i want my function to be f(x)= x^2? or x^n in general?
KSSV
KSSV 2021 年 1 月 11 日
These ar basic questions, you should read documentation to start with.
f = x.^n ; % element by elememnt operation
reshef caspi
reshef caspi 2021 年 1 月 11 日
thanks

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

その他の回答 (1 件)

WalterWhite
WalterWhite 2021 年 1 月 11 日

0 投票

Another way to get the solution
x(1,:) = 1:10; %x
x(2,:) = x(1,:).^x(1,:); %f(x)= x^x
x

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

質問済み:

2021 年 1 月 11 日

回答済み:

2021 年 1 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by