How to plot x and y with x evaluated in a function

It seems to be such an easy thing but I can't right remember
So, I've got an array of x values (2708x1) and y values(2708x1) and a function Amp(x). How to plot(Amp(x),y) ?

 採用された回答

madhan ravi
madhan ravi 2020 年 6 月 20 日

0 投票

x = ...;
y = ...;
plot(Amp(x),y)

4 件のコメント

Niklas Kurz
Niklas Kurz 2020 年 6 月 20 日
Thank you for you help, however something still goes wrong:
Amp = (6.344*10^(-7)*x^6 + 3.938*10^(-5)*x^5 -0.001053*x^4 -0.01953*x^3 + 0.2699*x^2 + -13.92*x + 502.4);
x = M{:,1};
y = M{:,2};
plot(Amp(x),y)
Niklas Kurz
Niklas Kurz 2020 年 6 月 20 日
I could type
Ampx = (6.344*10^(-7)*x.^6 + 3.938*10^(-5)*x.^5 -0.001053*x.^4 -0.01953*x.^3 + 0.2699*x.^2 + -13.92*x + 502.4);
and then
plot (Ampx, y)
But isn't there a faster way?
Niklas Kurz
Niklas Kurz 2020 年 6 月 20 日
I guess I posed my question in the wrong way, I'll re-ask it. Thank you for your effort :)
madhan ravi
madhan ravi 2020 年 6 月 20 日
Amp = @(x) 6.344*10^(-7)*x.^6 + 3.938*10^(-5)*x.^5 -0.001053*x.^4 -0.01953*x.^3 + 0.2699*x.^2 + -13.92*x + 502.4;
x = M{:,1};
y = M{:,2};
plot(Amp(x),y)

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by