How to find y-axis data for a certain x-axis value

11 views (last 30 days)
I've tried to find IM_Collapse_find_S1M for 5km, 10 km, 15 km but it's giving wrong values. Actually values will increase gradually from 5km to 15 km but through this code I'm getting opposite nature. I don't know why I'm getting such errors.
load MIDR_S1M.xlsx
load PGA_EQ.xlsx
PGA_Scale = [0.1:0.1:2.4];
xi = linspace(0,0.1,24);
MIDR_S1M_Rupture_5km = [MIDR_S1M(1,:);MIDR_S1M(4,:);MIDR_S1M(7,:);MIDR_S1M(10,:)];
MIDR_S1M_Rupture_10km = [MIDR_S1M(2,:);MIDR_S1M(5,:);MIDR_S1M(8,:);MIDR_S1M(11,:)];
MIDR_S1M_Rupture_15km = [MIDR_S1M(3,:);MIDR_S1M(6,:);MIDR_S1M(9,:);MIDR_S1M(12,:)];
for tt = 1:12
yi = interp1(MIDR_S1M(tt,:),PGA_EQ(tt,1)*PGA_Scale,xi,'nearest','extrap') ;
h1 = plot(xi,yi,'linewidth',1.5);hold on;
end
Desire_Limit_Collapse = 0.02; % values to be calculated from the graph corresponding this Desire_Limit_Collapse
for ii= 1:12
IM_Collapse_find_S1M(ii)= interp1(MIDR_S1M(ii,:),PGA_EQ(ii,1)*PGA_Scale,Desire_Limit_Collapse,'nearest','extrap');
end
IM_Collapse_find_S1M_Rupture_5km = [IM_Collapse_find_S1M(1,1);IM_Collapse_find_S1M(1,4);IM_Collapse_find_S1M(1,7);IM_Collapse_find_S1M(1,10)];
IM_Collapse_find_S1M_Rupture_10km = [IM_Collapse_find_S1M(1,2);IM_Collapse_find_S1M(1,5);IM_Collapse_find_S1M(1,8);IM_Collapse_find_S1M(1,11)];
IM_Collapse_find_S1M_Rupture_15km = [IM_Collapse_find_S1M(1,3);IM_Collapse_find_S1M(1,6);IM_Collapse_find_S1M(1,9);IM_Collapse_find_S1M(1,12)];

Answers (1)

dpb
dpb on 3 Aug 2021
Your X variable is repeating in sets of three so when you use all 12 elements as a vector it's multi-valued in y. interp1 then picks the first that it finds for any given Xi
The overall curve then looks like the following--
Above is from
MIDR_SIM=readmatrix('MIDR_S1M.xlsx');
PGA_EQ=readmatrix('PGA_EQ.xlsx');
plot(MIDR_SIM(:,1),PGA_EQ)
for the first column. You'll need to interpolate over the individual segments within the overall sets of 12 to avoid the multi-valued Y values to get the individual pieces.
  4 Comments
Sumit Saha
Sumit Saha on 3 Aug 2021
IM_Collapse_find_S1M_Rupture_5km = [1.077 0.877 0.657 0.607];
IM_Collapse_find_S1M_Rupture_10km = [1.699 1.31 0.96 0.879];
IM_Collapse_find_S1M_Rupture_15km = [2.716 1.939 1.4 1.329];
see this thing I got from excel interpolation and the trend of this data is right with my model. But if I remove the for end loop in this code and try to calculate it from individual plot (MIDR(1,:),PGA_EQ(1,1)*PGA_Scale) then also it's showing the wrong trend for this data points.
IM_Collapse_find_S1M = interp1(MIDR_S1M(1,:),PGA_EQ(1,1)*PGA_Scale,Desire_Limit_Collapse,'nearest','extrap');
dpb
dpb on 3 Aug 2021
I still don't follow what you're trying to do here -- can you explain the end objective?
What I do see is that for MIDR_S1M(1,:); there's a fairly smooth curve for first 22 points then the 23rd point is some value of 10E18! Whassup w/ that?

Sign in to comment.

Products


Release

R2017b

Community Treasure Hunt

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

Start Hunting!