Borrar filtros
Borrar filtros

switch command

5 visualizaciones (últimos 30 días)
Bestun
Bestun el 19 de Abr. de 2012
Dear all
I used switch command in my code for three different cases: Case 0, case 1 and case 2. But I couldn't run it because it gave error (asking for strip weight value).
function HenXoma(flag, rw, a, Yw, rd, rsat,xmax, ymax, edgeA, edgeB, edgeC, edgeD, cohesion, phiDegs, unitWeight)
switch flag;
case 0
dlorg(xmax, ymax, edgeA, edgeB, edgeC, edgeD, cohesion, phiDegs, unitWeight);
case 1
[rw a Yw rd rsat]= deal(9.81, 0.017, 0, 8.8, 15.2);
dlor(rw, a, Yw, rd, rsat,xmax, ymax, edgeA, edgeB, edgeC, edgeD, cohesion, phiDegs, unitWeight);
case 2
runtests (68.198, 0.5, 0.3, 0.2, 0.7, 1.2, 0.750821238038765, 1.077, 9.81, 0.00001, 8.8, 15.2, 2);
end
function dlor(rw, a, Yw, rd, rsat,xmax, ymax, edgeA, edgeB, edgeC, edgeD, cohesion, phiDegs, unitWeight)
dlorg(xmax, ymax, edgeA, edgeB, edgeC, edgeD, cohesion, phiDegs, unitWeight);
function dlorg(xmax, ymax, edgeA, edgeB, edgeC, edgeD, cohesion, phiDegs, unitWeight)
nodes = createNodes(xmax, ymax);
discs = createDiscontinuities(nodes, xmax, ymax, edgeA, edgeB, edgeC, edgeD);
B = compatibilityMatrix(nodes, discs);
[objP padN N] = plasticMultiplierTerms(nodes, discs, cohesion, phiDegs);
fD = selfWeight(nodes, discs, ymax, unitWeight);
fL = unitLoad(discs);
tied = tieDiscs(discs);
[vars, soln] = solve(B, N, padN, fD, fL, tied, objP);
plotMechanism(nodes, discs, vars, xmax, ymax);
soln
function fD = selfWeight(nodes, discs, ymax, unitWeight);
fD = [];
for i = 1 : size(discs, 1)
[n1 n2 len] = deal(discs(i, 1), discs(i, 2), discs(i, 4));
[cosine sine] = deal((nodes(n1, 2) - nodes(n2, 2)) / len, (nodes(n1, 3) - nodes(n2, 3)) / len);
%i
if flag == 0
stripWeight = computeStripWeight(nodes(n1,2), nodes(n1, 3), nodes(n2,2), nodes(n2, 3), unitWeight, ymax, len);
else if flag == 1
stripWeight1 = computeStripWeight1(nodes(n1,2), nodes(n1, 3), nodes(n2,2), nodes(n2, 3), unitWeight, ymax, len,rw, a, Yw, rd, rsat);
end
end
fD = [fD; -sine * stripWeight; -cosine * stripWeight];
[fD];
end
the flag is not recogibnzed by the code in the last function (function fD), therefore it is asking for value of strip weight. to create fD matrix, strip weight is required as shown in the last line ( fD = [fD; -sine * stripWeight; -cosine * stripWeight];)
This is the string of the input parameters
function HenXoma(flag, rw, a, Yw, rd, rsat,xmax, ymax, edgeA, edgeB, edgeC, edgeD, cohesion, phiDegs, unitWeight)
HenXoma(1 ,9.81, 0.017, 0, 8.8, 15.2, 1, 1, 0, 0, 4, 2, 0, 36.9, 15.2)
Ayn suggestion please?

Respuestas (1)

Walter Roberson
Walter Roberson el 19 de Abr. de 2012
When flag == 1 in selfWeight, you assign a value to the variable stripWeight1 but then after the "if" you use the variable stripWeight instead of stripWeight1

Categorías

Más información sobre Linear Programming and Mixed-Integer Linear Programming en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by