Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
questions for pdetool

Subject: questions for pdetool

From: Meng

Date: 24 Jul, 2013 01:48:10

Message: 1 of 5

When I use [ux,uy]=pdegrad(p,t,u); ux and uy are calculated in the center of each triangle. But how can I get the coordinates of the center in each triangle?

Subject: questions for pdetool

From: Alan_Weiss

Date: 24 Jul, 2013 12:41:51

Message: 2 of 5

On 7/23/2013 9:48 PM, Meng wrote:
> When I use [ux,uy]=pdegrad(p,t,u); ux and uy are calculated in the
> center of each triangle. But how can I get the coordinates of the
> center in each triangle?

This is documented here, among other places:
http://www.mathworks.com/help/pde/ug/scalar-coefficients-in-function-form.html

Here is a relevant code snippet:

% Triangle point indices
it1=t(1,:);
it2=t(2,:);
it3=t(3,:);

% Find centroids of triangles
xpts=(p(1,it1)+p(1,it2)+p(1,it3))/3;
ypts=(p(2,it1)+p(2,it2)+p(2,it3))/3;

Alan Weiss
MATLAB mathematical toolbox documentation

Subject: questions for pdetool

From: Meng

Date: 24 Jul, 2013 17:18:07

Message: 3 of 5

Alan_Weiss <aweiss@mathworks.com> wrote in message <ksoi2f$m61$1@newscl01ah.mathworks.com>...
> On 7/23/2013 9:48 PM, Meng wrote:
> > When I use [ux,uy]=pdegrad(p,t,u); ux and uy are calculated in the
> > center of each triangle. But how can I get the coordinates of the
> > center in each triangle?
>
> This is documented here, among other places:
> http://www.mathworks.com/help/pde/ug/scalar-coefficients-in-function-form.html
>
> Here is a relevant code snippet:
>
> % Triangle point indices
> it1=t(1,:);
> it2=t(2,:);
> it3=t(3,:);
>
> % Find centroids of triangles
> xpts=(p(1,it1)+p(1,it2)+p(1,it3))/3;
> ypts=(p(2,it1)+p(2,it2)+p(2,it3))/3;
>
> Alan Weiss
> MATLAB mathematical toolbox documentation


Thank you very much!
Another question is that Cp is calculated at the center of each triangle. How can I get the gradient of Cp ( d(Cp)/dx)?

Subject: questions for pdetool

From: Alan_Weiss

Date: 24 Jul, 2013 19:19:18

Message: 4 of 5

On 7/24/2013 1:18 PM, Meng wrote:
> Alan_Weiss <aweiss@mathworks.com> wrote in message
> <ksoi2f$m61$1@newscl01ah.mathworks.com>...
>> On 7/23/2013 9:48 PM, Meng wrote:
>> > When I use [ux,uy]=pdegrad(p,t,u); ux and uy are calculated in the
>> > center of each triangle. But how can I get the coordinates of the >
>> center in each triangle?
>> This is documented here, among other places:
>> http://www.mathworks.com/help/pde/ug/scalar-coefficients-in-function-form.html
>>
>>
>> Here is a relevant code snippet:
>>
>> % Triangle point indices
>> it1=t(1,:);
>> it2=t(2,:);
>> it3=t(3,:);
>>
>> % Find centroids of triangles
>> xpts=(p(1,it1)+p(1,it2)+p(1,it3))/3;
>> ypts=(p(2,it1)+p(2,it2)+p(2,it3))/3;
>>
>> Alan Weiss
>> MATLAB mathematical toolbox documentation
>
>
> Thank you very much! Another question is that Cp is calculated at the
> center of each triangle. How can I get the gradient of Cp ( d(Cp)/dx)?

I don't know what Cp is. But perhaps you can use (I didn't test this,
use caution):

Cpn = pdeprtni(p,t,Cp);
[Cpx,Cpy] = pdegrad(p,t,Cpn);

Alan Weiss
MATLAB mathematical toolbox documentation

Alan Weiss
MATLAB mathematical toolbox documentation

Subject: questions for pdetool

From: Meng

Date: 26 Jul, 2013 04:12:11

Message: 5 of 5

Alan_Weiss <aweiss@mathworks.com> wrote in message <ksp9bm$s23$1@newscl01ah.mathworks.com>...
> On 7/24/2013 1:18 PM, Meng wrote:
> > Alan_Weiss <aweiss@mathworks.com> wrote in message
> > <ksoi2f$m61$1@newscl01ah.mathworks.com>...
> >> On 7/23/2013 9:48 PM, Meng wrote:
> >> > When I use [ux,uy]=pdegrad(p,t,u); ux and uy are calculated in the
> >> > center of each triangle. But how can I get the coordinates of the >
> >> center in each triangle?
> >> This is documented here, among other places:
> >> http://www.mathworks.com/help/pde/ug/scalar-coefficients-in-function-form.html
> >>
> >>
> >> Here is a relevant code snippet:
> >>
> >> % Triangle point indices
> >> it1=t(1,:);
> >> it2=t(2,:);
> >> it3=t(3,:);
> >>
> >> % Find centroids of triangles
> >> xpts=(p(1,it1)+p(1,it2)+p(1,it3))/3;
> >> ypts=(p(2,it1)+p(2,it2)+p(2,it3))/3;
> >>
> >> Alan Weiss
> >> MATLAB mathematical toolbox documentation
> >
> >
> > Thank you very much! Another question is that Cp is calculated at the
> > center of each triangle. How can I get the gradient of Cp ( d(Cp)/dx)?
>
> I don't know what Cp is. But perhaps you can use (I didn't test this,
> use caution):
>
> Cpn = pdeprtni(p,t,Cp);
> [Cpx,Cpy] = pdegrad(p,t,Cpn);
>
> Alan Weiss
> MATLAB mathematical toolbox documentation
>
> Alan Weiss
> MATLAB mathematical toolbox documentation

Thank you very much! It does work.:)

Meng Wang

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us