Forgot password
 Register account
View 260|Reply 2

批量生成变量赋予随机值

[Copy link]

461

Threads

955

Posts

4

Reputation

Show all posts

青青子衿 posted 2023-4-21 06:06 |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

3203

Threads

7841

Posts

48

Reputation

Show all posts

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

3203

Threads

7841

Posts

48

Reputation

Show all posts

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

Quick Reply

Advanced Mode
B Color Image Link Quote Code Smilies
You have to log in before you can reply Login | Register account

$\LaTeX$ formula tutorial

Mobile version

2025-7-4 10:23 GMT+8

Powered by Discuz!

Processed in 0.022744 seconds, 25 queries