MATLAB Answers

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

1 view (last 30 days)
Niklas Kurz
Niklas Kurz on 20 Jun 2020
Commented: madhan ravi on 20 Jun 2020
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) ?

  0 Comments

Sign in to comment.

Accepted Answer

madhan ravi
madhan ravi on 20 Jun 2020
x = ...;
y = ...;
plot(Amp(x),y)

  4 Comments

Show 1 older comment
Niklas Kurz
Niklas Kurz on 20 Jun 2020
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 on 20 Jun 2020
I guess I posed my question in the wrong way, I'll re-ask it. Thank you for your effort :)
madhan ravi
madhan ravi on 20 Jun 2020
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)

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!