an assignment A(I) = B, the number of elements in B and I must be the same?
1 次查看(过去 30 天)
显示 更早的评论
clc
clear all
close
%B =(kg/cm2) % totally vertical over pressure
%Input File Input Regression(depth,rd,Vs).txt
file1='CobaReg.txt'
fid=fopen(file1, 'r');
Reg01=fscanf(fid,'%g %g %g', [3,Inf])';
rd =Reg01(:,1); % epicentre distance
depth=Reg01(:,2); % moment magnitude
Vs =Reg01(:,3); % peak ground surface acceleration
%Input PDF_Repi_Mw_amax_PGA.txt
file2='CobaEarthq.txt'
fid=fopen(file2, 'r');
Eq01=fscanf(fid,'%g %g %g', [3,Inf])';
Repi=Eq01(:,1); % epicentre distance
Mw =Eq01(:,2); % moment magnitude
amax=Eq01(:,3); % peak ground surface acceleration
%Input PDF_Repi_Mw_amax_PGA.txt
file3='SigReg.txt'
fid=fopen(file3, 'r');
Sig01=fscanf(fid,'%g %g', [2,Inf])';
SigmaR=Sig01(:,1); %shear stress from Laboratorium
SigmaD=Sig01(:,2); %shear stress from Earthquake
%X=[depth Vs Repi Mw amax];
% Regression rd
for i =1:length(depth)
%b = mvregress(X,rd)
X=[ones(size(depth)) depth Vs Repi Mw amax]
R=regress(SigmaR,X)
D=regress(SigmaD,X)
%stepwise(X,rd);
end
cftool
%Calculation SigmaD based on regression:
SigD=[]
for i=1:length(depth)
SigD(i)=D(1,1)+D(2,1)*depth(i)-D(3,1)*Vs(i)-D(4,1)*Repi(i)-D(5,1)*Mw-D(6,1)*amax(i);
end
My problem is In an assignment A(I) = B, the number of elements in B and I must be the same.
Error in Regression (line 57) SigD(i)=D(2,1)*depth(i)-D(3,1)*Vs(i)-D(4,1)*Repi(i)-D(5,1)*Mw-D(6,1)*amax(i);
Is there any one can help me?
2 个评论
回答(1 个)
KSSV
2017-11-30
Use this:
for i=1:length(depth)
SigD{i}=D(1,1)+D(2,1)*depth(i)-D(3,1)*Vs(i)-D(4,1)*Repi(i)-D(5,1)*Mw-D(6,1)*amax(i);
end
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Stress and Strain 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!