Group Abstract Group Abstract

Message Boards Message Boards

0
|
7.4K Views
|
7 Replies
|
7 Total Likes
View groups...
Share
Share this post:

[?] Connect data from solving equation in some loop?

Posted 8 years ago

My program about solving equation , then when it finished , by looping , by another order when you ask which answer of solving equation , it plot it . i think i describe it awfully !!!! enter image description here

POSTED BY: Saleh Baradaran
7 Replies
POSTED BY: Neil Singer
POSTED BY: Saleh Baradaran

Saleh,

I would do it all in a Dynamic Module. Using loops and inputs is not very Mathematica-like.

Here is an example:

DynamicModule[{M = 100, sols, n, beam = 1},
 sols = \[CapitalOmega] /. 
   Table[FindRoot[
     Tanh[Sqrt[\[CapitalOmega]]] - 
      Tan[Sqrt[\[CapitalOmega]]], {\[CapitalOmega], IG}], {IG, 10, 
     200, 50}];
 f[x_, n_] := 
  Sum[sols[[n]]^(2 i)/(4 i + 2)! x^(4 i + 2), {i, 0, M}] - 
   Sum[sols[[n]]^(2 i)/(4 i + 2)!, {i, 0, M}]/
     Sum[sols[[n]]^(2 i)/(4 i + 3)!, {i, 0, M}] Sum[
     sols[[n]]^(2 i)/(4 i + 3)! x^(4 i + 3), {i, 0, M}];
 Panel[Column[{Row[{"Single-Span:", 
      PopupMenu[
       Dynamic[beam], {1 -> "Free-Pinned", 2 -> "Clamped-Free"}], 
      Row[{"Mode:", SetterBar[Dynamic[n], Range[Length[sols]]]}]}],
    Dynamic[Plot[f[x, n], {x, 0, 1}, ImageSize -> Large]]}]]]

Which gives you a dynamic like this:

enter image description here

The SetterBar can be made to automatically resize based on how many modes there are in the solution. I obviously did not add any functionality to the beam type popup but you can do that. Use the dynamic variable "beam" to change your solution so the plot will change.

Regards,

Neil

POSTED BY: Neil Singer

Dear Neil

I must say you thank you many many times , your opinion is very attractive and i want it so you give it to me , but i want to know if i have 6 different beam with 6 different function and also 6 different sols , how can i put them in this program you suggest me?

I work on your program but since the I am new in mathematica programming , I cant solve it , So please help me more How can your program extended for 6 type of beam by 6 different function and 6 different Sols

Best regards

Saleh

Attachments:
POSTED BY: Saleh Baradaran
Posted 8 years ago

Perhaps

ClearAll["Global`*"];
M = 100;
sols = ? /. Table[FindRoot[Tanh[Sqrt[?]] - Tan[Sqrt[?]], {?, IG}], {IG, 10, 200, 50}];
f[x_, n_] := Sum[sols[[n]]^(2 i)/(4 i+2)! x^(4 i+2), {i,0,M}] - Sum[sols[[n]]^(2 i)/(4 i+2)!, {i,0,M}]/
     Sum[sols[[n]]^(2 i)/(4 i+3)!, {i,0,M}] Sum[sols[[n]]^(2 i)/(4 i+3)! x^(4 i+3), {i,0,M}];
n = Input["which mode do you want?"];
Plot[f[x, n], {x, 0, 1}]
POSTED BY: Bill Simpson

Thank you so much , yes your program is working , Thanks

I want to know if i want to put this program in loop or for , how can i do it? for example i want to say , ask user which beam do you want? if he say clamped free , the program choose clamped free that we define for it and do like the program above , then plot n mode for it ...

Thank you so much

POSTED BY: Saleh Baradaran

The error in your error is in red.

POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard