Find x for y=0 using interpolation
29 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Valentin Messerle
am 1 Jun. 2020
Kommentiert: Valentin Messerle
am 1 Jun. 2020
Hello there,
I was given the task to find the x value where y is 0 using interpolation. And I just can not figure it out on my own.
First of all: Here is my complete code:
load Daten_Wurfparabel.mat
h_index = find(y<0,1) ;
index = [ h_index-1 h_index] ;
xx = x(index) ;
yy = y(index) ;
x0 = xx(1)+1 ;
y0 = 0 ;
w = interp1( x , y , xx ) ;
% Plot
figure (1), clf
subplot(2,1,1)
hold on , grid on
plot(x ,y ,'ko-')
plot(xx,yy,'r*','markersize',10)
xlabel('x [m]'), ylabel('y [m]')
title('Wurfparabel y über x')
subplot(2,1,2)
hold on , grid on
plot(xx ,yy ,'ko-')
plot(xx,yy,'r*','markersize',10)
plot(x0, y0, 'ko')
xlim([19 21]), ylim([-0.5 1])
xlabel('x [m]'), ylabel('y [m]')
title('Vergrößerung des Nulldurchgangs')
% Ausgabe im CW
disp('Wurfweite [m] = x-Wert bei Nulldurchgang y = 0')
disp(x0(1))
As you can see. I'm loading data from a .mat file (x is a 21x1 matrix and y is a 21x1 matrix). I have attached the file below. If you paste my code into matlab, you can see that I'm off by a few centimeters. The solution should be 20.2479m and mine is currently 20.3990m.
Can someone please help me out?
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrix Indexing 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!