Hello Matlab Community, Can someone write sum loop for me as menstion in the image and how to use subscript 1 with Q..

2 Ansichten (letzte 30 Tage)

Antworten (2)

Walter Roberson
Walter Roberson am 26 Nov. 2022
A = rand(1,20); B = rand(1,20);
X = A./B;
%looped sum
total_looped = 0;
for Index = 1 : numel(X)
total_looped = total_looped + X(Index);
end
%Unlooped sum
total_unlooped = sum(X);
format long g
total_looped
total_looped =
35.8484976612101
total_unlooped
total_unlooped =
35.8484976612101
difference = total_looped - total_unlooped
difference =
0
  1 Kommentar
Umar Farooq
Umar Farooq am 28 Nov. 2022
thank you dear for your kind and reply. actually i have write in this way is it right?
w=[1.000 0.993 0.984 0.968 0.938 0.870 0.787 0.766 0.660 0.553 0.383 0.298 0.234 0.191 0.085]
d=[2.000 1.000 0.500 0.250 0.150 0.053 0.054 0.039 0.023 0.013 0.008 0.006 0.005 0.004 0.001]
di=d.*100
wi=(w.*1000)
%----------------------------------------------------------------------------------------------
ps=2.65; %partical desnity
eb=1.25; %bulk density
e=(ps-eb)/eb
n=15; %number of partical
Vvi=(wi/ps)*e; % pore volume
summation =0.0;
Vvi=[422.642 419.854 415.870 408.982 396.447 367.671 332.718 323.725 278.764 233.802 161.863 125.893 98.916 80.931 35.969]
Vb=[800 794.723 787.1829 774.144 750.417 695.948 629.787 612.7659 527.659 442.553 306.382 238.297 187.234 153.1914 68.085]
for i=1:n
Vb=summation.*(wi*(i))./eb;
summation = summation+Vvi*(i)/eb
teta_vi=summation.*(Vvi*(i)/Vb); %volumetric water content
end
theta=(teta_vi+teta_vi+1)/2; % Y- Grapgh volumtric water content

Melden Sie sich an, um zu kommentieren.


Umar Farooq
Umar Farooq am 28 Nov. 2022
Erro
Index in position 1 exceeds array bounds. Index must not exceed 1.
Error in New_Arya_Paris (line 27)
RI(i,j)=(di(i,j)+ di(i+1,j))/4000;
-------------------------------------------------------
Problm
w=[1.000 0.993 0.984 0.968 0.938 0.870 0.787 0.766 0.660 0.553 0.383 0.298 0.234 0.191 0.085]
d=[2.000 1.000 0.500 0.250 0.150 0.053 0.054 0.039 0.023 0.013 0.008 0.006 0.005 0.004 0.001]
di=d.*100
wi=(w.*1000)
ni=15
for j=1:1;
for i=1:(ni-1)
RI(i,j)=(di(i,j)+ di(i+1,j))/4000;
end
end

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by