Forgot password?
 Create new account
View 136|Reply 2

批量生成变量赋予随机值

[Copy link]

462

Threads

969

Posts

9934

Credits

Credits
9934

Show all posts

青青子衿 Posted at 2023-4-21 06:06:35 |Read mode
  1. Clear["`*"]
  2. lst1 = Flatten[
  3.    Table[Symbol[Evaluate["a" <> ToString[i] <> ToString[j]]], {i, 0,
  4.      3}, {j, 1, 3}]];
  5. lst2 = Flatten[RandomReal[{-2, 2}, {4, 3}]];
  6. data1 = {lst1, lst2}
  7. MapThread[(Clear[#1]; #1 = #2) &, data1]
Copy the Code

3147

Threads

8493

Posts

610K

Credits

Credits
66163
QQ

Show all posts

hbghlyj Posted at 2023-4-23 05:02:48
请问上面的
Flatten[RandomReal[{-2, 2}, {4, 3}]]
是否可以写成
RandomReal[{-2, 2}, 12]

3147

Threads

8493

Posts

610K

Credits

Credits
66163
QQ

Show all posts

hbghlyj Posted at 2023-4-27 21:46:11
请问Clear["`*"]Clear["Global`*"]是否等效

手机版Mobile version|Leisure Math Forum

2025-4-20 22:27 GMT+8

Powered by Discuz!

× Quick Reply To Top Return to the list