How to solve "Not enough input arguments."
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Jon
el 5 de Mayo de 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.
Respuestas (2)
cdawg
el 5 de Mayo de 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 comentarios
Jon
el 8 de Mayo de 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 comentarios
Ver también
Categorías
Más información sobre Fourier Analysis and Filtering en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!