Need To Find Value of Y at X for Curve Z. Detail Problem Explained in description
2 views (last 30 days)
Show older comments
Hi all.
Ill just brief my problem.
in this work i have extracted data of X, Y for Particular Z curve : I have 26 Z curves in varying size of X & Y; :Code Attached
xx = [X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26]; % size (50 x 1)
yy = [Y1 Y2 Y3 Y4 Y5 Y6 Y7 Y8 Y9 Y10 Y11 Y12 Y13 Y14 Y15 Y16 Y17 Y18 Y19 Y20 Y21 Y22 Y23 Y24 Y25 Y26]; % size (50 x 1)
zz = [5 6 7 8 9 10 12 14 16 18 20 25 30 35 40 50 60 70 80 90 100 120 150 200 250 300]; %for curve 5(X1,Y1) ... to 300 (X26,Y26)
in the above Code, X1 Y1 are same size(50X1) for Curve 5, (zz curve values are defined as 5, 6 and 10, 12 14 .. 150 200 250).
similarly for X2, Y2 for zz(2) =6;
similarly upto X26,Y26 for zz(26) = 300 ; (300 is curve value)
The plot looks like this below attached.
Question 1 : How to find Y value for 2 inputs of Z & X;
Input 1 : z = (between 200 and 150 - Say 165 I will give)
input 2 : xq value
Answer needed :
Output needed Yq = ????? How to get this.
Trying Grid data, Scattered data but my code is not working as zz value is not same size as X1 & Y1,
Please any help on this to get my result is really appricieted.
simply problem is if give any value of z and x i need y
0 Comments
Accepted Answer
Chunru
on 3 Sep 2021
Without knowing your data, the following code only gives you an idea:
z0 = [5 6 7 8 9 10 12 14 16 18 20 25 30 35 40 50 60 70 80 90 100 120 150 200 250 300];
for i = 1:length(z0)
xx{i, 1} = (0:.1:1)'; % the size can be varying with i
yy{i, 1} = xx{i}.^2 * (1/(i+2));
zz{i, 1} = z0(i) * ones(size(xx{i,1}));
end
% Assume your data is stored in the format avove
x = cell2mat(xx);
y = cell2mat(yy);
z = cell2mat(zz);
xq = 0.4; yq = 0.5;
whos
F = scatteredInterpolant(x,y,z);
zq = F(xq, yq)
5 Comments
More Answers (1)
KSSV
on 3 Sep 2021
Read about knnsearch, you provide (Y,Z) data and for a given (y,z) find which point is closest, get the index and assign the respective X value.
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!