Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 2-by-1.

2 次查看(过去 30 天)
Hello everyone, could someone help me with the error that I have in the next code?. The problem that I have is related with the title that I indicated before.
m=10; %Número de simulaciones
a=1; %Altura del talud.
hw=1; %Profundidad a la que se encuentra el nivel freático desde la superficie.
g=20; %Peso unitario del suelo
c=10; %Cohesión promedio.
fi=25; %Águlo de cohesión promedio.
b=15; %Ángulo de inclinación del talud.
covc=.3; %Covarianza de la cohesión.
covfi=.1; %Covarianza del tan(fi).
dstdc=covc*c; %Desviación estandard de c'
dstdfi=covfi*tand(fi); %Desviación estandard de tan(fi)
fs=zeros(m,a);
mfs=zeros(m,a);
dfs=zeros(m,a);
for h=1:a
for n=1:m
cfs (n,:)= (c+(-dstdc+(dstdc+dstdc)*rand));
fifs (n,:)= (tand(fi)+(-dstdfi+(dstdfi+dstdfi)*rand));
fs(n,h) = (1./(g*h*sind(b)*cosd(b))).*cfs+(cotd(b)-((9.81*(h-hw))./(g*h*tand(b)))).*fifs;
end
end

回答(1 个)

Image Analyst
Image Analyst 2019-6-17
cfs and fifs are both 2 values, so you're trying to stick two values into one index.
Change the fs line to this and see what you learn:
value = (1./(g*h*sind(b)*cosd(b))).*cfs+(cotd(b)-((9.81*(h-hw))./(g*h*tand(b)))).*fifs
fs(n,h) = value;
  1 个评论
Omar Andrés Rosada González
Thank you for the answer.
I tried this but it didn't work. What I pretend is the fs line save the values of each loop, and in the way that you propose me, I can´t do that. Could exist another way of do that?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by