Filter löschen
Filter löschen

take a value y of a function y = f(x) giving x.

2 Ansichten (letzte 30 Tage)
Francesco Pio
Francesco Pio am 3 Jun. 2023
Beantwortet: Star Strider am 3 Jun. 2023
Suppose we have the following code that creates the graph of the sine function:
x = 0:pi/100:2*pi;
y = sin(x);
plot(x,y)
Now I have the graph of the sine function. how can I get the value of the function by specifying the respective x-value? For example, how can I get the value of sin(51) based on the plot I created (it is not valid to use the matlab sine function)?

Antworten (1)

Star Strider
Star Strider am 3 Jun. 2023
Use an appropriate interpolation function, such as interp1 or just index into it, depending on what you want to do —
x = 0:pi/100:2*pi;
y = sin(x);
y51 = y(51);
plot(x,y)
hold on
plot(x(51), y(51), 'ms')
hold off
axis('padded')
.

Kategorien

Mehr zu Line Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by