How to solve "Not enough input arguments."
1 view (last 30 days)
Show older comments
function pinaka = pendatiagonal(e,c,d,a,b)
pinaka = pendatiagonal(e,c,d,a,b)
n = 7;
e = [0 0 round(10*rand(1,n-2))+1];
c = [0 round(10*rand(1,n-1))+1];
d = round(10*rand(1,n))+1;
a = [round(10*rand(1,n-1))+1 0];
b = [round(10*rand(1,n-2))+1 0 0];
e = e(3:end);
c = c(2:end);
a = a(1:end-1);
b = b(1:end-2);
diag(e,-2) + diag(c,-1) + diag(d,0) + diag(a,1) + diag(b,2);
disp(pinaka)
end
2 Comments
Jon
on 5 May 2023
It isn't clear at all what you are doing here.
It looks like you start out defining a function call pendatiagonal, but then in the next line you call it, then you start assigning the input variable you would need for calling this function. What exactly are you trying to do, please explain further.
Answers (2)
cdawg
on 5 May 2023
you're creating e, c, d, a, and b within the function.. it looks like n could be the only input. is this what you're trying to do?
n = 7;
pinaka = pendatiagonal(n)
function pinaka = pendatiagonal(n)
e = [0 0 round(10*rand(1,n-2))+1];
c = [0 round(10*rand(1,n-1))+1];
d = round(10*rand(1,n))+1;
a = [round(10*rand(1,n-1))+1 0];
b = [round(10*rand(1,n-2))+1 0 0];
e = e(3:end);
c = c(2:end);
a = a(1:end-1);
b = b(1:end-2);
pinaka = diag(e,-2) + diag(c,-1) + diag(d,0) + diag(a,1) + diag(b,2);
end
0 Comments
Jon
on 8 May 2023
You could also do it all with a very simple loop
pentadiagonal(7)
function pinaka = pentadiagonal(n)
pinaka = zeros(n,n);
for k = -2:2
pinaka = pinaka + diag(randi(10,n-abs(k),1),k);
end
end
0 Comments
See Also
Categories
Find more on Fourier Analysis and Filtering 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!