Modify subscripts - MATLAB Cody - MATLAB Central

Problem 2837. Modify subscripts

Difficulty:Rate

MATLAB supports object-oriented programming. Let's take an advantage of it in cody.

This problem starts here.

Let's take things a bit more seriously. There are subsasgn and subsref to overload:

>> A = sub_double([ 1 4 7
                    2 5 8
                    3 6 9]);
>> A([1 3],[3 1])
ans = 
    3x3 sub_double:
    double data:    
       7    3
>> A([1 2 3],[3 2 1]) = 0
A = 
    3x3 sub_double:
    double data:
       1     2     0
       4     0     6
       0     8     9
>> A(:)'
ans = 
    1x9 sub_double:
    double data:
       1     4     0     2     0     8     0     6     9
>> A(:,:)
ans = 
    1x3 sub_double:
    double data:
       1     0     9

Solution Stats

69.23% Correct | 30.77% Incorrect
Last Solution submitted on Aug 15, 2023

Problem Comments

Solution Comments

Show comments
MATLAB Central 2024 In Review
...
Let's celebrate what made 2024 memorable! Together, we made big impacts, hosted...

Problem Recent Solvers9

Suggested Problems

More from this Author40

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Go to top of page