Why this program keep saying Error using plotting>getC Too many output arguments. Error in plotting (line 9) res(i)=getC(1,0,100);? The getC returns c, which is only one output(a number),where're the 'too many' outputs?
Ältere Kommentare anzeigen
Here's my scripts,I'm new to Matlab and really couldn't figure out how to fix this problem...
function plotting
clc
close all
x = linspace(1,2,2);
res=zeros(1,length(x));
for i=1:length(x)
xpt=x(i);
res(i)=getC(1,0,100);
%res(i)=getC;
end
plot(x,res)
function getC(x,t,n)
c=0;
for k=1:1:n
c=c+(4*(-1).^k)/((2*k+1)*pi)*cos(((2*k+1)*pi)*x/2)*exp(((-(2*k+1)*pi)/2).^2*t);
end
getC = c;
Antworten (2)
Walter Roberson
am 7 Aug. 2017
Change
function getC(x,t,n)
c=0;
for k=1:1:n
c=c+(4*(-1).^k)/((2*k+1)*pi)*cos(((2*k+1)*pi)*x/2)*exp(((-(2*k+1)*pi)/2).^2*t);
end
getC = c;
to
function c = getC(x,t,n)
c=0;
for k=1:1:n
c=c+(4*(-1).^k)/((2*k+1)*pi)*cos(((2*k+1)*pi)*x/2)*exp(((-(2*k+1)*pi)/2).^2*t);
end
Kategorien
Mehr zu Axis Labels finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!