0
$\begingroup$
ClearAll["Global`*"];
Clear[b]
L = 4;
z1 = L/3;
Y = 2*10^11;
Iyy = 8.333*10^-6;
A = 0.1^2;
kbt = (Y*Iyy)/L^3;
kbr = (Y*Iyy)/L;
\[Rho] = 7850;
mb = 7850*A*L;
w1 = A1*Sin[b*x] + B1*Cos[b*x] + C1*Sinh[b*x] + E1*Cosh[b*x];
w2 = A2*Sin[b*(x - z1)] + B2*Cos[b*(x - z1)] + C2*Sinh[b*(x - z1)] + 
   E2*Cosh[b*(x - z1)];
w = Piecewise[{{w1, x <= z1}, {w2, x > z1}}];
(*SS BC*)
bcd0 = w1 /. {x -> 0};
bcm0 = (D[w1, {x, 2}]) /. {x -> 0};
bcdl = w2 /. {x -> L};
bcml = D[w2, {x, 2}] /. {x -> L};
(*Compatability condition for translation spring*)
ccd1 = (w1 /. {x -> z1}) - (w2 /. {x -> z1});
ccs1 = ((D[w1, {x}]) /. {x -> z1}) - ((D[w2, {x}]) /. {x -> z1});
ccm1 = ((D[w1, {x, 2}]) /. {x -> z1}) - ((D[w2, {x, 2}]) /. {x -> z1});
ccsh1 = ((D[w1, {x, 3}]) /. {x -> z1}) - ((D[w2, {x, 3}]) /. {x -> 
       z1}) + KT*(w1 /. {x -> z1});
(*Compatability condition for rotational spring*)
ccd2 = (w1 /. {x -> z1}) - (w2 /. {x -> z1});
ccs2 = ((D[w1, {x}]) /. {x -> z1}) - ((D[w2, {x}]) /. {x -> z1});
ccm2 = ((D[w1, {x, 2}]) /. {x -> z1}) - ((D[w2, {x, 2}]) /. {x -> 
       z1}) + KR*((D[w1, {x, 1}]) /. {x -> z1});
ccsh2 = ((D[w1, {x, 3}]) /. {x -> z1}) - ((D[w2, {x, 3}]) /. {x -> 
       z1});

(*Forming matrix for translational springs *)

RT = Normal@
   CoefficientArrays[{bcd0, bcm0, bcdl, bcml, ccd1, ccs1, ccm1, 
      ccsh1}, {A1, B1, C1, E1, A2, B2, C2, E2}][[2]];
R1 = MatrixForm[RT];
MatrixRank[RT];
P1 = FullSimplify[Det[RT]];
f[k1t_, beta_] := 
 Module[{m}, KT = k1t; r = beta; s1 = P1; 
  s2 = NSolve[s1 == 0 && 0 < b < 30]; s3 = b /. s2; s4 = Flatten[s3]; 
  s5 = s4[[r]]; {uu, ww, vv} = 
   SingularValueDecomposition[RT /. b -> s5];
  NN = Last[Transpose[vv]]; A1 = NN[ [1]]; B1 = NN[ [2]]; 
  C1 = NN[ [3]]; E1 = NN[ [4]]; A2 = NN[ [5]]; B2 = NN[ [6]]; 
  C2 = NN[ [7]]; E2 = NN[ [8]]; m = w /. b -> s5; Return[m]]

(*Forming matrix for rotational springs *)

Clear[b, A1, B1, C1, E1, A2, B2, C2, E2]
RR = Normal@
   CoefficientArrays[{bcd0, bcm0, bcdl, bcml, ccd2, ccs2, ccm2, 
      ccsh2}, {A1, B1, C1, E1, A2, B2, C2, E2}][[2]];
R2 = MatrixForm[RR];
MatrixRank[RR];
P2 = FullSimplify[Det[RR]];
g[k1r_, beta_] := 
 Module[{m}, KR = k1r; r = beta; s1 = P2; 
  s2 = NSolve[s1 == 0 && 0 < b < 30]; s3 = b /. s2; s4 = Flatten[s3]; 
  s5 = s4[[r]]; {uu, ww, vv} = 
   SingularValueDecomposition[RR /. b -> s5];
  NN = Last[Transpose[vv]]; A1 = NN[ [1]]; B1 = NN[ [2]]; 
  C1 = NN[ [3]]; E1 = NN[ [4]]; A2 = NN[ [5]]; B2 = NN[ [6]]; 
  C2 = NN[ [7]]; E2 = NN[ [8]]; m = w /. b -> s5; Return[m]]
n1 = 1;
n2 = 5;
soft = Table[f[0, i], {i, n1, n2}];
hardL = Table[f[1*^12, i], {i, n1, n2}];
hardR = Table[g[1*^12, i], {i, n1, n2}];
dim = Length[soft]*2 + Length[hardR];
modes = Flatten[{soft, hardL, hardR}];
Table[Plot[modes[[i]], {x, 0, L}], {i, 1, Length[modes]}]

I have a list of plots in which some plots are same. I just wanted to create the list which contains unique plots. How to do this. I don't want to do it manually. because the size of the list is going to increase. Is there any build in function in Mathematica to handle this situation. I don't know how to carry out this task, there is no Logic in my mind right now to code and remove this from the list.

$\endgroup$
1
  • $\begingroup$ When I evaluate the code, I do not see any plots that are the same. $\endgroup$ Commented Nov 17, 2018 at 17:26

1 Answer 1

2
$\begingroup$

This is fairly slow.

Using your code

plots = Plot[#, {x, 0, L}] & /@ modes

enter image description here

plots[[3]] and plots[[7]] are visually the same

delDupPlots[plots_, threshold : _Integer?Positive : 100] := 
 Fold[Drop[#1, {#2}] &, plots, 
  Select[Table[{i, j, 
        Total@Flatten[
          ImageData@Binarize@ImageDifference[plots[[i]], plots[[j]]]]}, {i, 1,
         Length[plots] - 1}, {j, i + 1, Length[plots]}] // 
      Flatten[#, 1] &, #[[3]] < threshold &][[All, 2]] // ReverseSort]

delDupPlots eliminates plots[[7]]

delDupPlots[plots]

enter image description here

$\endgroup$
2
  • $\begingroup$ Thanks a lot, it is working. I have implemented in my code. but could you brief how your function works? $\endgroup$
    – acoustics
    Commented Nov 18, 2018 at 7:31
  • 1
    $\begingroup$ Start with a small subset of images, say plots2 = plots[[{3,4,7}]]. Build the function up step-by-step looking at the output of each step. It just pairwise compares the images by counting the pixel differences in the binarized ImageDifference. If the count (Total) is below the set threshold the pair are considered the same. $\endgroup$
    – Bob Hanlon
    Commented Nov 18, 2018 at 14:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.