how can I solve this problem?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
I have the following set of data:
x=[0;0;0;0;0;1;1;1;1;1;2;2;2;2;2];
y=[0;1;2;3;4;0;1;2;3;4;0;1;2;3;4];
z=[10;11;12;13;14;15;16;17;18;19;20;21;22;23;24];
Now I want to know what the value of y and z if I x=1.
To solve this problem, I have tried to use the function interp2. But I get an error.
Can somebody help me with this?
Thanks :)
0 commentaires
Réponses (2)
Jacob Wood
le 26 Fév 2020
Hi Sharon,
This is a perfect application for Matlab's logical indexing.
x_is_one = x == 1; %find locations where x=1
y_select = y(x_is_one); %pick y where x=1
z_select = z(x_is_one); %pick z where x=1
2 commentaires
Jacob Wood
le 26 Fév 2020
Hi Sharon,
It doesn't look like X=1 at any point in this example. Would you instead like to interpolate the vectors, and see what y and z would be when x theoretically crosses 1?
x=[0.01,3,6,9,12,15,18];
y=[0.6113,0.7577,0.9349,1.1477,1.4022,1.7051,2.0640];
z=[206.136,168.132,137.734,113.386,93.784,77.926,65.038];
y_select = interp1(x,y,1);
z_select = interp1(x,z,1);
Voir également
Catégories
En savoir plus sur Interpolation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!