Returning even column and row in a matrix
1 view (last 30 days)
Show older comments
Hi, I got a problem with some error with my home work. The requirement is created a function that can return the even column and even row.
Here is what i do
function even_index(M)
A=M(2:2:end,2:2:end)
end
how ever when i put to command window something like even_index([ 2 1 3 4; 3 2 2 1; 4 3 2 1; 7 8 5 6])
Matlab said: Error: File: even_index.m Line: 13 Column 77
Invalid experession
I saved the file into matlab already but I have the same problem with three function I created
Could someone help me explain it. Appreciate it
1 Comment
Adam
on 25 Feb 2020
Your function only has about 5 lines as you have shown it here so I don't know how it could error on Line 13 unless the function is bigger than you show.
What does
which even_index
point to? And when you open what it points to is it the function you expect it to be?
Also, if you select the 'Pause on errors' option from the Run dropdown menu in the editor before calling your code in the command window it will stop on the line that has the error.
Answers (0)
See Also
Categories
Find more on Entering Commands in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!