Creating a matrix with specific sequence
조회 수: 3 (최근 30일)
이전 댓글 표시
I was given this as a homework assignment but I am not really sure where to even start. Would this be a loop creation? Nested loop?
The script should assume values are specified on a command line before being run. The script should be able to take values of a, b, c, and n, and output a 3-x-n matrix B such that
B = [a a^2 ... a^n; b 2b ... nb; nc (n-1)c ... c]
Proper execution of the script would appear as follows:
>> a = 2; b = 3; c = 4; n = 3;
>> script18
B =
2 4 8
3 6 9
12 8 4
Note that this script should function for any integer values of a, b, c and n.
댓글 수: 2
답변 (1개)
참고 항목
카테고리
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!