Fix the function hlp
Show older comments
i was told to write funciton for this: but it keeps saying something is wrong but i dont know what is wrong with it .

function [ arr ] =special_matrix( n )
if n>2
for i = 1:n
for j = 1:n
if mod(j,3)==0
arr(i,j)}=((i-1)*n+j}^j;
else
arr(i,j)={i-1}*n+j;
end
end
end
else
disp('Error; n must be greater than i')
end
end
3 Comments
Walter Roberson
on 26 Jan 2021
arr(i,j)}=((i-1)*n+j}^j;
You have two } each not matched by previous {
{} in MATLAB is only used for cell arrays or working with composite objects like tables. It is never used for prioritization. prioritization is only through () brackets
Sam Chak
on 23 Nov 2023
The original question may be beneficial for people who wish to learn how to create special square matrices.

Rena Berman
on 27 Nov 2023
(Answers Dev) Restored edit
Accepted Answer
More Answers (0)
Categories
Find more on Call Python from MATLAB 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!