TransWikia.com

Initialize Global variables with manipulate

Mathematica Asked by Quang Trần Minh on September 28, 2021

I would like to use the result from a dynamic matrix for calculation, but I don’t know how to return a global variable from manipulate. Please help me, I’m new to mathematica. Any suggestion would be highly appreciated. PS: Most of these codes are not from me, I googled it and applied it, acknowledge to the original authors.

   Manipulate[{mat[[;; k, ;; l]], "hello", mat2[[;; k, ;; l]], 
  aa[[;; k, 1]], bb[[1, ;; l]]}, {{mat, ConstantArray[0, {50, 50}]}, 
  None}, {{mat2, ConstantArray[0, {50, 50}]}, 
  None}, {{aa, ConstantArray[0, {50, 50}]}, 
  None}, {{bb, ConstantArray[0, {50, 50}]}, None}, {k, 3, None}, {l, 
  4, None}, Dynamic[Row[
   {Column[{
      Row[{Style["size m: ", 14, "Panel"], 
        InputField[Dynamic[k, (k = Clip[IntegerPart@#, {2, 20}]) &], 
         Number, FieldSize -> {4, 1}], 
        Style["  size n:", 14, "Panel"], 
        InputField[Dynamic[l, (l = Clip[IntegerPart@#, {2, 20}]) &], 
         Number, FieldSize -> {4, 1}]}],
      Style["Ai: ", 14, "Panel"],
      Table[
       With[{xi = i, yj = 1}, 
        InputField[Dynamic[aa[[xi, 1]]], ImageSize -> 50]], {i, k}],
      Style["Bj: ", 14, "Panel"],
      Table[
       With[{xi = 1, yj = j}, 
        InputField[Dynamic[bb[[1, yj]]], ImageSize -> 50]], {j, l}],
      Style["Ma tran cuoc phi: ", 14, "Panel"],
      Table[
        With[{xi = i, yj = j}, 
         InputField[Dynamic[mat[[xi, yj]]], ImageSize -> 50]], {i, 
         k}, {j, l}] // TableForm,
      Style["Ma tran hieu suat: ", 14, "Panel"],
      Table[
        With[{xi = i, yj = j}, 
         InputField[Dynamic[mat2[[xi, yj]]], ImageSize -> 50]], {i, 
         k}, {j, l}] // TableForm
      }, Alignment -> Top]}, Spacer[5]]]]

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP