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 (최근 30일)
이전 댓글 표시
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
채택된 답변
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!