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:
carpet plot

Subject: carpet plot

From: Sebastian

Date: 9 Mar, 2011 19:10:06

Message: 1 of 6

Hey guys,

I have been trying to make a so called carpet plot. Apparently no one knows what it is so have a look at the following link...

http://www.ascgenoa.com/main/newsletter/16/figure_4.jpg

also here is the program I made so far... hope that helps to understand the issue I have.

a=0.3:-0.15:-0.3;
b=0.3:-0.15:-0.3;
for ia=1:length(a)
    for ib=1:length(b)
         vf1(ia,ib) = sqrt(3/(-(5/3).*a(ia)+b(ib)+2.*sqrt((a(ia)/3).*((4/3).*a(ia)-b(ib)))));
         vf2(ia,ib) = sqrt(3/(-(5/3).*a(ia)+b(ib)-2.*sqrt((a(ia)/3).*((4/3).*a(ia)-b(ib)))));
    end
end
format('longEng')
vf1
vf2

[X,Y]=meshgrid(0.3:-0.15:-0.3);

so basically i get a matrix called vf1 and vf2. I then need to plot a so called carpet plot for both vf1 and vf2 on separate diagrams. a should be on the y axis and b on the x axis. now vf1 is then plotted for each combination of a and b. There suppose to be 5 vertical lines represented by the variation of b and 5 horizontal lines represented by the variation of a. I hope the link above helps.

I think a good start is using meshgrid for the axis...

Thanks in advance

Seb

Subject: carpet plot

From: Alan B

Date: 9 Mar, 2011 20:29:03

Message: 2 of 6

"Sebastian " <sebastian.meng@meng-muenchen.de> wrote in message <il8jae$5u9$1@fred.mathworks.com>...
> Hey guys,
>
> I have been trying to make a so called carpet plot. Apparently no one knows what it is so have a look at the following link...
>
> http://www.ascgenoa.com/main/newsletter/16/figure_4.jpg
>
> also here is the program I made so far... hope that helps to understand the issue I have.
>
> a=0.3:-0.15:-0.3;
> b=0.3:-0.15:-0.3;
> for ia=1:length(a)
> for ib=1:length(b)
> vf1(ia,ib) = sqrt(3/(-(5/3).*a(ia)+b(ib)+2.*sqrt((a(ia)/3).*((4/3).*a(ia)-b(ib)))));
> vf2(ia,ib) = sqrt(3/(-(5/3).*a(ia)+b(ib)-2.*sqrt((a(ia)/3).*((4/3).*a(ia)-b(ib)))));
> end
> end
> format('longEng')
> vf1
> vf2
>
> [X,Y]=meshgrid(0.3:-0.15:-0.3);
>
> so basically i get a matrix called vf1 and vf2. I then need to plot a so called carpet plot for both vf1 and vf2 on separate diagrams. a should be on the y axis and b on the x axis. now vf1 is then plotted for each combination of a and b. There suppose to be 5 vertical lines represented by the variation of b and 5 horizontal lines represented by the variation of a. I hope the link above helps.
>
> I think a good start is using meshgrid for the axis...
>
> Thanks in advance
>
> Seb


You can plot your data like this:
plot(vf1,vf2,'g',vf1',vf2','b')

But there is some problem with your domain or your transformation - some of your vf values are complex, or significantly larger than the others

Also, you can avoid those for loops:
[a b] = meshgrid(.3:-.15:-.3);
vf1 = sqrt(3./(-(5/3).*a+b+2.*sqrt((a/3).*((4/3).*a-b))));
vf2 = sqrt(3./(-(5/3).*a+b-2.*sqrt((a/3).*((4/3).*a-b))));

Subject: carpet plot

From: Sebastian

Date: 9 Mar, 2011 20:38:03

Message: 3 of 6

"Alan B" <monguin61REM@OVETHIS.yahoo.com> wrote in message <il8nuf$92t$1@fred.mathworks.com>...
> "Sebastian " <sebastian.meng@meng-muenchen.de> wrote in message <il8jae$5u9$1@fred.mathworks.com>...
> > Hey guys,
> >
> > I have been trying to make a so called carpet plot. Apparently no one knows what it is so have a look at the following link...
> >
> > http://www.ascgenoa.com/main/newsletter/16/figure_4.jpg
> >
> > also here is the program I made so far... hope that helps to understand the issue I have.
> >
> > a=0.3:-0.15:-0.3;
> > b=0.3:-0.15:-0.3;
> > for ia=1:length(a)
> > for ib=1:length(b)
> > vf1(ia,ib) = sqrt(3/(-(5/3).*a(ia)+b(ib)+2.*sqrt((a(ia)/3).*((4/3).*a(ia)-b(ib)))));
> > vf2(ia,ib) = sqrt(3/(-(5/3).*a(ia)+b(ib)-2.*sqrt((a(ia)/3).*((4/3).*a(ia)-b(ib)))));
> > end
> > end
> > format('longEng')
> > vf1
> > vf2
> >
> > [X,Y]=meshgrid(0.3:-0.15:-0.3);
> >
> > so basically i get a matrix called vf1 and vf2. I then need to plot a so called carpet plot for both vf1 and vf2 on separate diagrams. a should be on the y axis and b on the x axis. now vf1 is then plotted for each combination of a and b. There suppose to be 5 vertical lines represented by the variation of b and 5 horizontal lines represented by the variation of a. I hope the link above helps.
> >
> > I think a good start is using meshgrid for the axis...
> >
> > Thanks in advance
> >
> > Seb
>
>
> You can plot your data like this:
> plot(vf1,vf2,'g',vf1',vf2','b')
>
> But there is some problem with your domain or your transformation - some of your vf values are complex, or significantly larger than the others
>
> Also, you can avoid those for loops:
> [a b] = meshgrid(.3:-.15:-.3);
> vf1 = sqrt(3./(-(5/3).*a+b+2.*sqrt((a/3).*((4/3).*a-b))));
> vf2 = sqrt(3./(-(5/3).*a+b-2.*sqrt((a/3).*((4/3).*a-b))));

Hey,

thanks for your reply but that desnt look right :(

i wish i could upload a picture to show you how it looks like since i have an example in front of me.

any ideas?

Subject: carpet plot

From: TideMan

Date: 9 Mar, 2011 20:49:18

Message: 4 of 6

On Mar 10, 9:38 am, "Sebastian " <sebastian.m...@meng-muenchen.de>
wrote:
> "Alan B" <monguin61...@OVETHIS.yahoo.com> wrote in message <il8nuf$92...@fred.mathworks.com>...
> > "Sebastian " <sebastian.m...@meng-muenchen.de> wrote in message <il8jae$5u...@fred.mathworks.com>...
> > > Hey guys,
>
> > > I have been trying to make a so called carpet plot. Apparently no one knows what it is so have a look at the following link...
>
> > >http://www.ascgenoa.com/main/newsletter/16/figure_4.jpg
>
> > > also here is the program I made so far... hope that helps to understand the issue I have.
>
> > > a=0.3:-0.15:-0.3;
> > > b=0.3:-0.15:-0.3;
> > > for ia=1:length(a)
> > >     for ib=1:length(b)
> > >          vf1(ia,ib) = sqrt(3/(-(5/3).*a(ia)+b(ib)+2.*sqrt((a(ia)/3).*((4/3).*a(ia)-b(ib)))));
> > >          vf2(ia,ib) = sqrt(3/(-(5/3).*a(ia)+b(ib)-2.*sqrt((a(ia)/3).*((4/3).*a(ia)-b(ib)))));
> > >     end
> > > end
> > > format('longEng')
> > > vf1
> > > vf2
>
> > > [X,Y]=meshgrid(0.3:-0.15:-0.3);
>
> > > so basically i get a matrix called vf1 and vf2. I then need to plot a so called carpet plot for both vf1 and vf2 on separate diagrams. a should be on the y axis and b on the x axis. now vf1 is then plotted for each combination of a and b. There suppose to be 5 vertical lines represented by the variation of b and 5 horizontal lines represented by the variation of a. I hope the link above helps.
>
> > > I think a good start is using meshgrid for the axis...
>
> > > Thanks in advance
>
> > > Seb
>
> > You can plot your data like this:
> > plot(vf1,vf2,'g',vf1',vf2','b')
>
> > But there is some problem with your domain or your transformation - some of your vf values are complex, or significantly larger than the others
>
> > Also, you can avoid those for loops:
> > [a b] = meshgrid(.3:-.15:-.3);
> > vf1 = sqrt(3./(-(5/3).*a+b+2.*sqrt((a/3).*((4/3).*a-b))));
> > vf2 = sqrt(3./(-(5/3).*a+b-2.*sqrt((a/3).*((4/3).*a-b))));
>
> Hey,
>
> thanks for your reply but that desnt look right :(
>
> i wish i could upload a picture to show you how it looks like since i have an example in front of me.
>
> any ideas?

You don't seem to be able to describe what you want, and the link you
gave earlier was not helpful - it looked like an x-t phase plane with
characteristics, i.e., the solution of a hyperbolic PDE.

What have you tried?
What is wrong with:
mesh(a,b,vf1)
or
surf(a,b,vf1)
or
contourf(a,b,vf1)

Please try each of these and tell us why they do not do what you want.

Subject: carpet plot

From: Sebastian

Date: 9 Mar, 2011 21:38:03

Message: 5 of 6

TideMan <mulgor@gmail.com> wrote in message <1127f76f-627f-45f8-905a-8d094eff6597@o21g2000prh.googlegroups.com>...
> On Mar 10, 9:38 am, "Sebastian " <sebastian.m...@meng-muenchen.de>
> wrote:
> > "Alan B" <monguin61...@OVETHIS.yahoo.com> wrote in message <il8nuf$92...@fred.mathworks.com>...
> > > "Sebastian " <sebastian.m...@meng-muenchen.de> wrote in message <il8jae$5u...@fred.mathworks.com>...
> > > > Hey guys,
> >
> > > > I have been trying to make a so called carpet plot. Apparently no one knows what it is so have a look at the following link...
> >
> > > >http://www.ascgenoa.com/main/newsletter/16/figure_4.jpg
> >
> > > > also here is the program I made so far... hope that helps to understand the issue I have.
> >
> > > > a=0.3:-0.15:-0.3;
> > > > b=0.3:-0.15:-0.3;
> > > > for ia=1:length(a)
> > > >     for ib=1:length(b)
> > > >          vf1(ia,ib) = sqrt(3/(-(5/3).*a(ia)+b(ib)+2.*sqrt((a(ia)/3).*((4/3).*a(ia)-b(ib)))));
> > > >          vf2(ia,ib) = sqrt(3/(-(5/3).*a(ia)+b(ib)-2.*sqrt((a(ia)/3).*((4/3).*a(ia)-b(ib)))));
> > > >     end
> > > > end
> > > > format('longEng')
> > > > vf1
> > > > vf2
> >
> > > > [X,Y]=meshgrid(0.3:-0.15:-0.3);
> >
> > > > so basically i get a matrix called vf1 and vf2. I then need to plot a so called carpet plot for both vf1 and vf2 on separate diagrams. a should be on the y axis and b on the x axis. now vf1 is then plotted for each combination of a and b. There suppose to be 5 vertical lines represented by the variation of b and 5 horizontal lines represented by the variation of a. I hope the link above helps.
> >
> > > > I think a good start is using meshgrid for the axis...
> >
> > > > Thanks in advance
> >
> > > > Seb
> >
> > > You can plot your data like this:
> > > plot(vf1,vf2,'g',vf1',vf2','b')
> >
> > > But there is some problem with your domain or your transformation - some of your vf values are complex, or significantly larger than the others
> >
> > > Also, you can avoid those for loops:
> > > [a b] = meshgrid(.3:-.15:-.3);
> > > vf1 = sqrt(3./(-(5/3).*a+b+2.*sqrt((a/3).*((4/3).*a-b))));
> > > vf2 = sqrt(3./(-(5/3).*a+b-2.*sqrt((a/3).*((4/3).*a-b))));
> >
> > Hey,
> >
> > thanks for your reply but that desnt look right :(
> >
> > i wish i could upload a picture to show you how it looks like since i have an example in front of me.
> >
> > any ideas?
>
> You don't seem to be able to describe what you want, and the link you
> gave earlier was not helpful - it looked like an x-t phase plane with
> characteristics, i.e., the solution of a hyperbolic PDE.
>
> What have you tried?
> What is wrong with:
> mesh(a,b,vf1)
> or
> surf(a,b,vf1)
> or
> contourf(a,b,vf1)
>
> Please try each of these and tell us why they do not do what you want.

Ok , sorry to keep on bothering you. Mesh and surface will not work since it is complex. Contour does work however the graph doesn't look at all how it suppose to be. I tried to use the real part of the complex numbers only but the graphs all look wrong

Maybe this helps. Below is a quite unusual looking coordinate system. The intersections of the lines are the values of the matrix vf1. Taking the values a = -0.15 and b = 0.15 the value of vf1 can then be seen at the intersection of those 2 lines. In reality the lines are curved. I do not know how to explain it in other words.

Thank you for your help!

y
| b
| -0.3 -0.15 0 0.15 0.3
| | | | | |
|--------------------------------------------- 0.3
| | | | | |
|--------------------------------------------- 0.15
| | | | | |
|--------------------------------------------- 0 a
| | | | | |
|--------------------------------------------- -0.15
| | | | | |
|--------------------------------------------- -0.3
| | | | | |
|------------------------------------------------------->x

Subject: carpet plot

From: Alan B

Date: 10 Mar, 2011 15:57:06

Message: 6 of 6

"Sebastian " <sebastian.meng@meng-muenchen.de> wrote in message <il8rvr$37g$1@fred.mathworks.com>...
> TideMan <mulgor@gmail.com> wrote in message <1127f76f-627f-45f8-905a-8d094eff6597@o21g2000prh.googlegroups.com>...
> > On Mar 10, 9:38 am, "Sebastian " <sebastian.m...@meng-muenchen.de>
> > wrote:
> > > "Alan B" <monguin61...@OVETHIS.yahoo.com> wrote in message <il8nuf$92...@fred.mathworks.com>...
> > > > "Sebastian " <sebastian.m...@meng-muenchen.de> wrote in message <il8jae$5u...@fred.mathworks.com>...
> > > > > Hey guys,
> > >
> > > > > I have been trying to make a so called carpet plot. Apparently no one knows what it is so have a look at the following link...
> > >
> > > > >http://www.ascgenoa.com/main/newsletter/16/figure_4.jpg
> > >
> > > > > also here is the program I made so far... hope that helps to understand the issue I have.
> > >
> > > > > a=0.3:-0.15:-0.3;
> > > > > b=0.3:-0.15:-0.3;
> > > > > for ia=1:length(a)
> > > > >     for ib=1:length(b)
> > > > >          vf1(ia,ib) = sqrt(3/(-(5/3).*a(ia)+b(ib)+2.*sqrt((a(ia)/3).*((4/3).*a(ia)-b(ib)))));
> > > > >          vf2(ia,ib) = sqrt(3/(-(5/3).*a(ia)+b(ib)-2.*sqrt((a(ia)/3).*((4/3).*a(ia)-b(ib)))));
> > > > >     end
> > > > > end
> > > > > format('longEng')
> > > > > vf1
> > > > > vf2
> > >
> > > > > [X,Y]=meshgrid(0.3:-0.15:-0.3);
> > >
> > > > > so basically i get a matrix called vf1 and vf2. I then need to plot a so called carpet plot for both vf1 and vf2 on separate diagrams. a should be on the y axis and b on the x axis. now vf1 is then plotted for each combination of a and b. There suppose to be 5 vertical lines represented by the variation of b and 5 horizontal lines represented by the variation of a. I hope the link above helps.
> > >
> > > > > I think a good start is using meshgrid for the axis...
> > >
> > > > > Thanks in advance
> > >
> > > > > Seb
> > >
> > > > You can plot your data like this:
> > > > plot(vf1,vf2,'g',vf1',vf2','b')
> > >
> > > > But there is some problem with your domain or your transformation - some of your vf values are complex, or significantly larger than the others
> > >
> > > > Also, you can avoid those for loops:
> > > > [a b] = meshgrid(.3:-.15:-.3);
> > > > vf1 = sqrt(3./(-(5/3).*a+b+2.*sqrt((a/3).*((4/3).*a-b))));
> > > > vf2 = sqrt(3./(-(5/3).*a+b-2.*sqrt((a/3).*((4/3).*a-b))));
> > >
> > > Hey,
> > >
> > > thanks for your reply but that desnt look right :(
> > >
> > > i wish i could upload a picture to show you how it looks like since i have an example in front of me.
> > >
> > > any ideas?
> >
> > You don't seem to be able to describe what you want, and the link you
> > gave earlier was not helpful - it looked like an x-t phase plane with
> > characteristics, i.e., the solution of a hyperbolic PDE.
> >
> > What have you tried?
> > What is wrong with:
> > mesh(a,b,vf1)
> > or
> > surf(a,b,vf1)
> > or
> > contourf(a,b,vf1)
> >
> > Please try each of these and tell us why they do not do what you want.
>
> Ok , sorry to keep on bothering you. Mesh and surface will not work since it is complex. Contour does work however the graph doesn't look at all how it suppose to be. I tried to use the real part of the complex numbers only but the graphs all look wrong
>
> Maybe this helps. Below is a quite unusual looking coordinate system. The intersections of the lines are the values of the matrix vf1. Taking the values a = -0.15 and b = 0.15 the value of vf1 can then be seen at the intersection of those 2 lines. In reality the lines are curved. I do not know how to explain it in other words.
>
> Thank you for your help!
>
> y
> | b
> | -0.3 -0.15 0 0.15 0.3
> | | | | | |
> |--------------------------------------------- 0.3
> | | | | | |
> |--------------------------------------------- 0.15
> | | | | | |
> |--------------------------------------------- 0 a
> | | | | | |
> |--------------------------------------------- -0.15
> | | | | | |
> |--------------------------------------------- -0.3
> | | | | | |
> |------------------------------------------------------->x


Run this:


[a b] = meshgrid(.3:-.15:-.3);
vf = [a(:) b(:)]*randn(2);
vf1 = reshape(vf(:,1),size(a));
vf2 = reshape(vf(:,2),size(a));
clf,
plot(vf1,vf2,'k.'), hold on
plot(vf1,vf2,'g')
plot(vf1',vf2','b')
text(vf1(:,1),vf2(:,1),num2str(vf1(:,1)),'color','b')
text(vf1(1,:),vf2(1,:),num2str(vf2(:,2)),'color','g')

To me, this looks essentially identical, in character, to your linked example. If I am wrong, try to explain, in depth, why it is not what you want. If I am right, then there may be something wrong with either your (a,b) domain, or your transformation from (a,b) to (vf1,vf2). For example, how are you expecting to plot pairs of complex values (four real values) as points in a 2D plane (two real coordinates)?

Tags for 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