x=[0 0.038 0.0785 0.168 0.272 0.395 0.539]; y=[0 0.005 0.01 0.02 0.03 0.04 0.05]; If these data are fitted to a curve, how can I find a value of x for y? for instance I want to find the value of x for y=0.025
MATLAB: Inverse evaluation – Find x value for a y value
Related Solutions
This imports and parses your example file:
str = fileread('Data.txt');str = regexprep(str,{'= ','[\r\n]+SNC','[\r\n]+'},{'= NaN ','/SNC',' '});fmt = ['%s%s%s%s%f%s%f%s%f%s%f',repmat('%s=%f',1,31)];opt = {'EndOfLine','/', 'MultipleDelimsAsOne',true};C = textscan(str,fmt,opt{:});V = [C{5:2:end}]K = [C{4:2:end}]
You can easily convert K and V into a table:
>> T = array2table(V,'VariableNames',K(1,:))T = AVE SMP AZI SDQ x y z T xsig ysig zsig Tsig xycov xzcov xTcov yzcov yTcov zTcov psig qsig rsig tp tq tr ustar Tstar Cd MOs mf hf u v w vel dir ___ ___ ___ ___ ____ ____ _____ _____ _____ _____ _____ _____ ______ ______ ______ ______ _____ ______ _____ _____ _____ _____ _____ _____ ______ ______ ________ _____ ______ ___ ____ ____ _____ ____ _____ 10 10 0 100 3.38 3 -0.21 17.06 0.842 0.616 0.386 0.082 -0.058 0.136 -0.022 -0.046 0.003 -0.009 0.706 0.763 0.395 0.155 0.168 0.087 -0.296 NaN -0.00427 NaN 0.106 -11 3 3.38 -0.21 4.52 221.6 10 10 0 100 3.08 3.17 0.03 17.1 0.754 0.688 0.482 0.097 0.224 -0.118 0.029 -0.105 0.016 -0.015 0.861 0.547 0.485 0.194 0.123 0.109 0.403 -0.038 0.00828 0.002 -0.197 -18 3.17 3.08 0.03 4.42 225.7 10 10 0 100 3.43 2.36 -0.13 17.1 0.65 0.766 0.508 0.072 0.001 -0.075 -0.004 -0.209 0.014 -0.008 0.699 0.729 0.496 0.167 0.175 0.119 0.416 -0.02 0.00998 0.001 -0.21 -10 2.36 3.43 -0.13 4.16 214.5
and also include the SNC values if required:
>> T = [cell2table(strcat(C{2:3}),'VariableNames',C{1}(1)),T]T = SNC AVE SMP AZI SDQ x y z T xsig ysig zsig Tsig xycov xzcov xTcov yzcov yTcov zTcov psig qsig rsig tp tq tr ustar Tstar Cd MOs mf hf u v w vel dir _________________ ___ ___ ___ ___ ____ ____ _____ _____ _____ _____ _____ _____ ______ ______ ______ ______ _____ ______ _____ _____ _____ _____ _____ _____ ______ ______ ________ _____ ______ ___ ____ ____ _____ ____ _____ '011031104000UTC' 10 10 0 100 3.38 3 -0.21 17.06 0.842 0.616 0.386 0.082 -0.058 0.136 -0.022 -0.046 0.003 -0.009 0.706 0.763 0.395 0.155 0.168 0.087 -0.296 NaN -0.00427 NaN 0.106 -11 3 3.38 -0.21 4.52 221.6 '011031104010UTC' 10 10 0 100 3.08 3.17 0.03 17.1 0.754 0.688 0.482 0.097 0.224 -0.118 0.029 -0.105 0.016 -0.015 0.861 0.547 0.485 0.194 0.123 0.109 0.403 -0.038 0.00828 0.002 -0.197 -18 3.17 3.08 0.03 4.42 225.7 '011031104020UTC' 10 10 0 100 3.43 2.36 -0.13 17.1 0.65 0.766 0.508 0.072 0.001 -0.075 -0.004 -0.209 0.014 -0.008 0.699 0.729 0.496 0.167 0.175 0.119 0.416 -0.02 0.00998 0.001 -0.21 -10 2.36 3.43 -0.13 4.16 214.5
Try this:
x = [0;0.03;0.03;0.01;0.01;0;0.02;0.02;0.01;0;0.01;0.02;0.015;0.005;0.025;0.03;0.025;0.01;0.005;0;0.01;0.005;0];y = [0;0;0.01;0.01;0.04;0.04;0;0.01;0.025;0.025;0;0.005;0.01;0.005;0;0.005;0.01;0.0175;0.025;0.0125;0.0325;0.04;0.0325];z = [0.002071017;0.002090221;0.001384402;0.001358957;0;0;0.002078694;0.001373731;0.000432053;0.000422168;0.002069412;0.001727074;0.001369789;0.001713017;0.002084764;0.00173648;0.00137873;0.000855225;0.000414625;0.001187851;0.000125043;0;0.000124721];N = 15;xv = linspace(min(x), max(x), N);yv = linspace(min(y), max(y), N);[X,Y] = ndgrid(xv, yv);Z = griddata(x,y,z,X,Y,'linear');figurecontourf(X, Y, Z, 'ShowText','on')xlabel('x')ylabel('y')
Change āNā to get different results.
Best Answer