How do i extract 'x' and 'y'data from 'z'data? f(x,y)=z
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have 'x' data, 'y' data, 'z1' data 'z2' data.
It has two variable values('z1', 'z2') at the same coordinates(x,y).
x : an integer from 1 to 13
y : an integer from 1 to 19
Z1: 13*19
I used cftool to plot the mesh. ( Interpolation)
How do I extract 'x' and 'y' data from 'z1' 'z2'?
I want to estimate the coordinates by comparing the x,y data( extracted through z1)
with the x,y data (extracted through z2).
A simple example is similar to finding approximate coordinates by estimating longitude based on time and latitude based on temperature, (confined to a northern (lower hemisphere) region.)
After moving the cftool result to the workspace (name: fittedmodel_z1), in the command window, use a value with a decimal point, not an integer, within the range (~13, ~19) for x and y, such as 'fittedmodel_z1(10.1,3.7)' When I give the command, I can get z1 data.
How do I do it in reverse?
I want to use f(x,y)=a , but I don't know the function f(x,y) .
Cannot use formula(fittedmodel_Z1).
>> formula(fittedmodel_Z1)
ans =
'piecewise linear surface'
I just want to know the coordinates through the overlapping part like the red hatched part in the picture below.
How about using artificial intelligence like a classification model? Or fuzzy?
Thank you.
1 commentaire
Mathieu NOE
le 8 Sep 2021
hello
you need to do a 2D interpolation , see :
help interp2
interp2 2-D interpolation (table lookup).
Réponses (1)
TED MOSBY
le 9 Juin 2024
Hi Lilo,
To estimate the coordinates ‘x’ and ‘y’ from the values ‘z1’ and ‘z2’, given that you have models ‘fittedmodel_z1’ and ‘fittedmodel_z2’ you need to perform an inverse prediction. There isn't a direct function in MATLAB for performing this inverse operation, you'll have to use an optimization approach where you minimize the difference between the observed (z) values and the model predictions for (z).
- Create an objective function that will calculate the error:
function error = objectiveFunctionZ1(xy, z1_observed, fittedmodel_z1)
% xy is a vector where xy(1) = x and xy(2) = y
% Calculate the predicted z1 based on the current x and y
z1_predicted = feval(fittedmodel_z1, xy(1), xy(2));
% Calculate the difference (error) between observed and predicted z1
error = abs(z1_predicted - z1_observed);
end
- You can use MATLAB’s optimization functions such as “fminsearch“to find the (x) and (y) that minimize the error defined in your objective function as shown below:
% Observed z1 value for which you want to find the corresponding x and y
z1_observed = 5; % Example value
% Initial guess for x and y
initialGuess = [6, 10]; % Adjust based on your data range
% Optimization to find x and y that minimize the error for z1
[estimatedXY, fval] = fminsearch(@(xy) objectiveFunctionZ1(xy, z1_observed, fittedmodel_z1), initialGuess, options);
% Extracting estimated x and y
estimatedX = estimatedXY(1);
estimatedY = estimatedXY(2);
- Repeat the above steps for z2
You may refer to the MATLAB documentation for “fminsearch” here:
Hope it helps!
0 commentaires
Voir également
Catégories
En savoir plus sur Statistics and Machine Learning Toolbox 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!