Need To Find Value of Y at X for Curve Z. Detail Problem Explained in description

1 回表示 (過去 30 日間)
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

採用された回答

Chunru
Chunru 2021 年 9 月 3 日
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
Name Size Bytes Class Attributes i 1x1 8 double x 286x1 2288 double xq 1x1 8 double xx 26x1 4992 cell y 286x1 2288 double yq 1x1 8 double yy 26x1 4992 cell z 286x1 2288 double z0 1x26 208 double zz 26x1 4992 cell
F = scatteredInterpolant(x,y,z);
Warning: Duplicate data points have been detected and removed - corresponding values have been averaged.
zq = F(xq, yq)
zq = 309.2008
  5 件のコメント
Chunru
Chunru 2021 年 9 月 3 日
編集済み: Chunru 2021 年 9 月 3 日
Then use "whos" to show the relevant variable sizes.
naveen kumar s
naveen kumar s 2021 年 9 月 3 日
Thank you @Chunru
Its Working well.

サインインしてコメントする。

その他の回答 (1 件)

KSSV
KSSV 2021 年 9 月 3 日
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.
  1 件のコメント
naveen kumar s
naveen kumar s 2021 年 9 月 3 日
Ok, i will read on that.
Thank you.
Yes i should provide X, Z data to get X at nearest. How to do this is what i am searching

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeScatter Plots についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by