Info
This question is closed. Reopen it to edit or answer.
I'm getting the error 'Subscripted assignment dimension mismatch.' for this piece of code (the last line: s(1,i)). Could anyone help me to figure out what is wrong and how to fix it? Thank you very much.
1 view (last 30 days)
Show older comments
for i=1:n
suma1 = 0;
b=(nchoosek(q,1))*(sa1_func(t));
c=((s2_func(t)));
f=(nchoosek(q,2))*(sa2_func(t));
g=s1_func(t);
suma1 = suma1 + (b.*c)*z(1,i,1)+(f.*g)*z(1,i,2) ;
s(1,i) = (1/(h^q))*((s_func(t))*x(1,i)+(sa_func(t))*x(1,i+1)+ suma1) ;
end;
5 Comments
Answers (2)
Walter Roberson
on 29 Jan 2017
You have
v = linspace(t(i),t(i+1),n);
so your v is a vector. Then
b=(nchoosek(q,j))*((v-t(i)).^j);
c=(t(i+1)-v).^(q-j);
Because v is a vector, b and c are going to be vectors.
suma11 = suma11 + (b.*c)*z(m-1,i,j);%+(f.*g)*z(1,i,2) ;
vector .* vector gives vector, so suma11 is going to be a vector.
e= (1/(h^q))*((t(i+1)-v).^q)*x(m-1,i);
r=(1/(h^q))*((v-t(i)).^q)*x(m-1,i+1);
v is a vector, so e and r are going to be vectors.
s(1,i) = e+r+ suma11 ; %here is the error
e and r and suma11 are vectors, so the right hand side is a vector. But the left hand side is one individual location. You cannot store a vector into an individual location. suma11=(1/(h^q))*suma11;
suma11 is already a vector and this just scales it, leaving it a vector.
0 Comments
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!