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

조회 수: 1(최근 30일)
Sumit Saha 2021년 8월 3일
댓글: dpb 2021년 8월 3일
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.
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)];

댓글을 달려면 로그인하십시오.

### 답변(1개)

dpb 2021년 8월 3일
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
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표시숨기기 이전 댓글 수: 3
dpb 2021년 8월 3일
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?

댓글을 달려면 로그인하십시오.

R2017b

### Community Treasure Hunt

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

Start Hunting!

Translated by