What changes should I make to save the values of P? P should at least be a 2×2 matrix!!

2 views (last 30 days)
this is the code:
for k=1:10
n=2*k-1
a1=sin((n*pi.*x)/b);
a2=sinh(n*pi.*y/b);
a3=n*sinh(n*pi*a/b);
sum=sum+c.*a1.*a2/a3;
P=[n, sum]
end

Answers (2)

Andrei Bobrov
Andrei Bobrov on 14 Mar 2016
n = (1:2:19)';
t = n*pi/b;
P = [n, cumsum(c*sin(t*x).*sinh(t*y)./sinh(t*a)./n)];

Walter Roberson
Walter Roberson on 14 Mar 2016
P(k,:) = [n, sum];
Note: do not name a variable "sum", as that interferes with the key MATLAB routine "sum"

Categories

Find more on Loops and Conditional Statements 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!