How do I multiply the numbers in a 2D array using a for loop, must be a for loop as part of the course requirements
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi everyone, this is very basic stuff but I'm new to this. All the steps so far are required by the course.
B=[1:24]
B=reshape(B,6,4)'
A1=B(:,4)
A2=B([2 4],[1 4])
B([3 4],[5 6])=[0 1;1 0]
The next step it to 'create a matrix A3 (using a for/end loop) that has coefficients which are the square of the sine of the corresponding values in matrix B (in degrees), eg. if B(2,3)=20, then A3(2,3)=0.1170',
Now, I'm ok with the sin^2 bit, I managed to get an array with but not using a for loop.
>> sin(B*pi/180).^2
ans =
0.0003 0.0012 0.0027 0.0049 0.0076 0.0109
0.0149 0.0194 0.0245 0.0302 0.0364 0.0432
0.0506 0.0585 0.0670 0.0760 0 0.0003
0.1060 0.1170 0.1284 0.1403 0.0003 0
We need to know how to use the for loop for this for later stage work.
Any help would be greatly appreciated, thank you
0 commentaires
Réponse acceptée
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!