フィルターのクリア

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

1 回表示 (過去 30 日間)
Skydriver
Skydriver 2017 年 11 月 29 日
コメント済み: Skydriver 2017 年 11 月 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
Torsten 2017 年 11 月 30 日
Maybe "Mw(i)" instead of "Mw" in the equation for SigD(i) ?
Best wishes
Torsten.

サインインしてコメントする。

回答 (1 件)

KSSV
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
  1 件のコメント
Skydriver
Skydriver 2017 年 11 月 30 日
Thank you, my program has already running

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeNumerical Integration and Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by