- #1
DryRun
Gold Member
- 838
- 4
I have attached the problem to this post. My attempt at the first part (i used 'm' instead of 'l' as it's less confusing, since the latter resembles the digit '1') and here is my script:
The answer:
A =
0.4546 -0.3502 -0.8330 -0.5500 0.2387 0.8080 0.6344 -0.1224 -0.7667 -0.7061
0.4913 -0.3784 -0.9002 -0.5944 0.2579 0.8731 0.6855 -0.1323 -0.8285 -0.7630
0.0762 -0.0587 -0.1397 -0.0922 0.0400 0.1355 0.1064 -0.0205 -0.1286 -0.1184
-0.4089 0.3149 0.7492 0.4947 -0.2147 -0.7267 -0.5706 0.1101 0.6895 0.6350
-0.5181 0.3991 0.9493 0.6268 -0.2720 -0.9207 -0.7229 0.1395 0.8737 0.8046
-0.1510 0.1163 0.2766 0.1826 -0.0793 -0.2683 -0.2107 0.0407 0.2546 0.2344
0.3550 -0.2734 -0.6504 -0.4294 0.1864 0.6308 0.4953 -0.0956 -0.5986 -0.5513
0.5346 -0.4117 -0.9795 -0.6467 0.2806 0.9500 0.7459 -0.1440 -0.9014 -0.8301
0.2227 -0.1715 -0.4080 -0.2694 0.1169 0.3957 0.3107 -0.0600 -0.3755 -0.3458
-0.2939 0.2264 0.5386 0.3556 -0.1543 -0.5224 -0.4101 0.0792 0.4957 0.4565
which i hope is correct?
But i have no idea how to do the same thing with a loop-free script.
Code:
A = zeros(10);
for k=1:10
for m=1:10
A(k,m) = sin(k)*cos(m);
end
end
A
The answer:
A =
0.4546 -0.3502 -0.8330 -0.5500 0.2387 0.8080 0.6344 -0.1224 -0.7667 -0.7061
0.4913 -0.3784 -0.9002 -0.5944 0.2579 0.8731 0.6855 -0.1323 -0.8285 -0.7630
0.0762 -0.0587 -0.1397 -0.0922 0.0400 0.1355 0.1064 -0.0205 -0.1286 -0.1184
-0.4089 0.3149 0.7492 0.4947 -0.2147 -0.7267 -0.5706 0.1101 0.6895 0.6350
-0.5181 0.3991 0.9493 0.6268 -0.2720 -0.9207 -0.7229 0.1395 0.8737 0.8046
-0.1510 0.1163 0.2766 0.1826 -0.0793 -0.2683 -0.2107 0.0407 0.2546 0.2344
0.3550 -0.2734 -0.6504 -0.4294 0.1864 0.6308 0.4953 -0.0956 -0.5986 -0.5513
0.5346 -0.4117 -0.9795 -0.6467 0.2806 0.9500 0.7459 -0.1440 -0.9014 -0.8301
0.2227 -0.1715 -0.4080 -0.2694 0.1169 0.3957 0.3107 -0.0600 -0.3755 -0.3458
-0.2939 0.2264 0.5386 0.3556 -0.1543 -0.5224 -0.4101 0.0792 0.4957 0.4565
which i hope is correct?
But i have no idea how to do the same thing with a loop-free script.
Attachments
Last edited: