How to fix error "Error using reshape To RESHAPE the number of elements must not change." when I am using pdegrad?
1 view (last 30 days)
Show older comments
How to fix error "Error using reshape To RESHAPE the number of elements must not change." when I am using pdegrad?
I want to calculate du/dx and du/dy by using pdegrad:
[ux,uy] = pdegrad(p,t,u);
Then I got error above. I wrote edit reshape on the command line, and it tells me that when I want to reshape u using function uu=reshape(u,np,N), I have to make sure my u has np by N elements. I checked my u elements size is 832 by 41 where 832 is my solutions from the nodes points and 41 is my tlist. Then on pdegrad function, it defines N=size(u,1)/np, where size(u,1) is 832 and np is 832 since it only has 1 partial derivative equation so N is 1. Therefore my u has a size of 832 by 1.
Is there any way to fix this error or other way to calculate the du/dx and du/dy?
Thank you, Bella
0 Comments
Accepted Answer
Alan Weiss
on 9 Feb 2016
I think that you need to compute pdegrad at each time separately. So try
[ux1,uy1] = pdegrad(p,t,u(:,1));
[ux2,uy2] = pdegrad(p,t,u(:,2));
% etc.
Alan Weiss
MATLAB mathematical toolbox documentation
3 Comments
More Answers (0)
See Also
Categories
Find more on Call Python from MATLAB 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!