an assignment A(I) = B, the number of elements in B and I must be the same?

1 view (last 30 days)
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?

Answers (1)

KSSV
KSSV on 30 Nov 2017
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

Categories

Find more on Numerical Integration and Differential Equations in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!