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
Torsten
2017년 11월 30일
Maybe "Mw(i)" instead of "Mw" in the equation for SigD(i) ?
Best wishes
Torsten.
답변 (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에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!