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:
what plot command can i use on my graph

Subject: what plot command can i use on my graph

From: matlab_learner

Date: 25 Aug, 2010 02:02:39

Message: 1 of 12

I'm supposed to do a plot on the x and y axis for different materials.
the problem is that the x axis data has a range on some of the subset
of data. i believe they should all be on 1 graph, but if u wanted to
do 2 graphs, one for the fibers and one for the traditional materials
that is ok, i could then see if i can modify your code.

I dont know what command to use given the difference in data sets (See
the difference below).

I did a little matlab (actually the only programming language i have
an idea of :-)

modulus %(on the y- axis)
%Material type: Fibers
eglass=28.5;
sglass= 34.5;
graphiteHiE = 205;
graphiteHiTS= 126;
Boron=146;
Silica = 33;
Tungsten= 21;
Beryllium = 131;
Kevlar49= 87;

Material type: Traditional materials
steel=26;
Al alloys= 25.9;
Glass= 28;
Tungs2=18.1;
Beryllium2=164;



Strength (on the x-axis of the graph)

Material type: Fibers
eglass=1.38;
sglass= 1.85;
graphiteHiE = 1.1;
graphiteHiTS= 1.3;
Boron=1.1;
Silica = 2.65;
Tungsten= 0.22;
Beryllium = 0.71;
Kevlar49=1.87;

Material type: Traditional materials
steel=.043 to .27; %(these datasets are in ranges)
Al alloys= .052 to 0.23;
Glass=.028 to .84;
Tungs2=057 to .21;
Beryllium2=.38;

Anyone who has an idea is appreciated. I'm at wits end at this point.
Thanks so much

Subject: what plot command can i use on my graph

From: ImageAnalyst

Date: 25 Aug, 2010 02:24:26

Message: 2 of 12

I'm not sure what's being plotted or how. Is it an x,y line curve? A
bar chart? A scatter plot? Anyway, once you've got them plotted, you
can use xlim() and ylim() to set up a common range for all the data
sets so that they all can fit on the plot at one time. Be sure to use
"hold on" in between plotting them or subsequent plots will destroy
earlier ones.

Subject: what plot command can i use on my graph

From: TideMan

Date: 25 Aug, 2010 02:43:54

Message: 3 of 12

On Aug 25, 2:02 pm, matlab_learner <cib...@gmail.com> wrote:
> I'm supposed to do a plot on the x and y axis for different materials.
> the problem is that the x axis data has a range on some of the subset
> of data. i believe they should all be on 1 graph, but if u wanted to
> do 2 graphs, one for the fibers and one for the traditional materials
> that is ok, i could then see if i can modify your code.
>
> I dont know what command to use given the difference in data sets (See
> the difference below).
>
> I did a little matlab (actually the only programming language i have
> an idea of :-)
>
> modulus %(on the y- axis)
> %Material type: Fibers
> eglass=28.5;
> sglass= 34.5;
> graphiteHiE = 205;
> graphiteHiTS= 126;
> Boron=146;
> Silica = 33;
> Tungsten= 21;
> Beryllium = 131;
> Kevlar49= 87;
>
> Material type: Traditional materials
> steel=26;
> Al alloys= 25.9;
> Glass= 28;
> Tungs2=18.1;
> Beryllium2=164;
>
> Strength (on the x-axis of the graph)
>
> Material type: Fibers
> eglass=1.38;
> sglass= 1.85;
> graphiteHiE = 1.1;
> graphiteHiTS= 1.3;
> Boron=1.1;
> Silica = 2.65;
> Tungsten= 0.22;
> Beryllium = 0.71;
> Kevlar49=1.87;
>
> Material type: Traditional materials
> steel=.043 to .27; %(these datasets are in ranges)
> Al alloys= .052 to 0.23;
> Glass=.028 to .84;
> Tungs2=057 to .21;
> Beryllium2=.38;
>
> Anyone who has an idea is appreciated. I'm at wits end at this point.
> Thanks so much

I think you'd be better using Excel for this task.
Excel is set up for witless charting such as this, whereas Matlab is
more appropriate for plotting vectors of one variable as a function of
one or two others.

Subject: what plot command can i use on my graph

From: matlab_learner

Date: 25 Aug, 2010 03:01:17

Message: 4 of 12

It is an x-y curve.

The problem is the range of data in the traditional material section
on the y axis.

IF I am to use Excel how will I do it?

I had tried this in Matlab but it didn't work:

clc
clear all
modulus = [28.5 34.5 205 126 146 33 21 131 87 26.9 25.9 28 18.1 164];
strength = [1.38 1.85 1.1 1.3 1.1 2.65 .22 .71 1.87 .043-.27 .052-.23 .
28-.84 .057-.21 .38];

plot(strength,modulus)

Subject: what plot command can i use on my graph

From: Matt Fig

Date: 25 Aug, 2010 03:40:21

Message: 5 of 12

matlab_learner <cibeji@gmail.com> wrote in message <18e54bb8-dbd8-4935-8973-21d2d18e9db1@v35g2000prn.googlegroups.com>...
> It is an x-y curve.
>
> The problem is the range of data in the traditional material section
> on the y axis.
>
> IF I am to use Excel how will I do it?
>
> I had tried this in Matlab but it didn't work:
>
> clc
> clear all
> modulus = [28.5 34.5 205 126 146 33 21 131 87 26.9 25.9 28 18.1 164];
> strength = [1.38 1.85 1.1 1.3 1.1 2.65 .22 .71 1.87 .043-.27 .052-.23 .
> 28-.84 .057-.21 .38];
>
> plot(strength,modulus)


What do you mean "it didn't work." If you want help, you need to be as specific as possible. When I copy and paste what you posted, I get a plot. So I would say that "it did work."

Subject: what plot command can i use on my graph

From: matlab_learner

Date: 25 Aug, 2010 04:24:26

Message: 6 of 12

The plot it gives isn't right. The problem once again is

SOME OF THE DATA FOR THE TRADITIONAL MATERIAL on JUST ONE OF THE AXIS
IS A RANGE!!! IF YOU LOOKED AT WHAT MATLAB DID WITH THE CODE I PASTED
IT IS SUBTRACTING THE GIVEN BOUNDS (FOR EXAMPLE .043 minus .27) WHICH
IS NOT A RANGE!!!!!! if it was that easy i won't b soliciting
assistance!!!

is it clearer now????

i mean, u can plot anything, but does it loook right is the question?
so if u have an idea how i can mark these ranges:
Material type: Traditional materials
steel=FROM 0.043 TO .27; %(these datasets are in ranges)
Al alloys= FROM .052 TO 0.23; %(these datasets are in ranges)
Glass= FROM .028 TO .84; %(these datasets are in ranges)
Tungs2=FROM 0.057 TO .21; %(these datasets are in ranges)

ON MY AXIS that would b terrific. THANKS ONCE AGAIN!!!!

Subject: what plot command can i use on my graph

From: Walter Roberson

Date: 25 Aug, 2010 04:57:17

Message: 7 of 12

On 24/08/10 11:24 PM, matlab_learner wrote:
> The plot it gives isn't right. The problem once again is
>
> SOME OF THE DATA FOR THE TRADITIONAL MATERIAL on JUST ONE OF THE AXIS
> IS A RANGE!!! IF YOU LOOKED AT WHAT MATLAB DID WITH THE CODE I PASTED
> IT IS SUBTRACTING THE GIVEN BOUNDS (FOR EXAMPLE .043 minus .27) WHICH
> IS NOT A RANGE!!!!!!

MATLAB DOES NOT SUPPORT RANGES OR HAVE ANY NOTATION TO INDICATE A RANGE
ON INPUT.

MATLAB did exactly what you told it to do: the notation you used *is*
subtraction notation to MATLAB.

You will have to find a way to reframe your inputs so as to be able to
distinguish the low end and high end of a range, and you will have to
find a way to explain what you would like the plot to look like. To
emphasize this point: I recognized that you were _attempting_ to
designate ranges upon my first reading of your initial question, but I
haven't responded because you have yet to describe what you are trying
to _do_ with the values.

Subject: what plot command can i use on my graph

From: matlab_learner

Date: 25 Aug, 2010 05:46:41

Message: 8 of 12

You will have to find a way to reframe your inputs so as to be able to
distinguish the low end and high end of a range, and you will have to
find a way to explain what you would like the plot to look like. To
emphasize this point: I recognized that you were _attempting_ to
designate ranges upon my first reading of your initial question, but I
haven't responded because you have yet to describe what you are trying
to _do_ with the values.

Ok, here, take a look at this code, where u tell matlab to do a range.
trick is to make all the data i used in this code to be on the x axis
and then the easier set of data on the y axis.


M = [
1.38%eglass
1.85%sglass
1.1%graphiteHiE
1.3%graphiteHiTS
1.1%Boron
2.65%Silica
0.22%Tungsten
0.71%Beryllium
1.87%Kevlar49
];
names = {
'eglass'
'sglass'
'graphiteHiE'
'graphiteHiTS'
'Boron'
'Silica'
'Tungsten'
'Beryllium'
'Kevlar49'
};

pie(M)
legend(names)
%Traditional materials
steel=[.043 .27];
Al_alloys= [.052 .23];
Glass=[.028 .84];
Tungs2=[.057 .21];
Beryllium2=.38;
figure
bar(1,steel(2),'BaseValue',steel(1))
hold on
bar(2,Al_alloys(2),'r','BaseValue',Al_alloys(1))
bar(3,Glass(2),'g','BaseValue',Glass(1))
bar(4,Tungs2(2),'k','BaseValue',Tungs2(1))
legend('steel','Al alloys','Glass','Tungs2')
figure
m = [ .043 .27
      .052 .23
      .028 .84
      .057 .21];
errorbar(1:4,mean(m,2),m(:,2)-mean(m,2),'LineStyle','none')
set(gca,'xtick',1:4,'xticklabel',{'steel','Al
alloys','Glass','Tungs2'})

Subject: what plot command can i use on my graph

From: ImageAnalyst

Date: 25 Aug, 2010 12:19:14

Message: 9 of 12

On Aug 24, 11:01 pm, matlab_learner <cib...@gmail.com> wrote:
> It is an x-y curve.
>
> The problem is the range of data in the traditional material section
> on the y axis.
>
> IF I am to use Excel how will I do it?
>
> I had tried this in Matlab but it didn't work:
>
> clc
> clear all
> modulus = [28.5 34.5 205 126 146 33 21 131 87 26.9 25.9 28 18.1 164];
> strength = [1.38 1.85 1.1 1.3 1.1 2.65 .22 .71 1.87 .043-.27 .052-.23 .
> 28-.84 .057-.21 .38];
>
> plot(strength,modulus)

---------------------------------------------------------------------------------
You can't put ranges into an array with the minus sign. Ranges in
MATLAB use the colon and you need to give a step for floating point
values. For example, take off the semicolon and look how MATLAB
performs the SUBTRACTION of "0.043 - 0.27" and "0.052-0.23" and so on:
strength =
    1.3800 1.8500 1.1000 1.3000 1.1000 2.6500
0.2200 0.7100 1.8700 -0.2270 -0.1780 -0.5600 -0.1530
0.3800
Look - there's no range in there, it actually did the subtraction
because it thought the "-" in between the two numbers meant
subtraction. It didn't know that it meant some kind of continuous
range to you. To do a range, you'd have to do
range1 = .043 : .001 : .270 % Middle number is the increment
- use whatever you want.
But be aware that the number of elements that this has depends on your
increment, and you'll have to have one element in modulus for every
single element in strength.

Subject: what plot command can i use on my graph

From: Steven_Lord

Date: 25 Aug, 2010 16:55:40

Message: 10 of 12



"matlab_learner" <cibeji@gmail.com> wrote in message
news:7685c7ce-2d16-439c-911b-32aae4f3e3b4@p11g2000prf.googlegroups.com...
> The plot it gives isn't right. The problem once again is
>
> SOME OF THE DATA FOR THE TRADITIONAL MATERIAL on JUST ONE OF THE AXIS
> IS A RANGE!!! IF YOU LOOKED AT WHAT MATLAB DID WITH THE CODE I PASTED
> IT IS SUBTRACTING THE GIVEN BOUNDS (FOR EXAMPLE .043 minus .27) WHICH
> IS NOT A RANGE!!!!!! if it was that easy i won't b soliciting
> assistance!!!
>
> is it clearer now????

Take a deep breath and calm down, please.

Now, can you state specifically how you want the graph to appear for those
materials? Do you want some sort of errorbar plot where the errorbar covers
the range of the values that material property can take?

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/errorbar.html

If not, can you link to a picture that shows the type of graph that you
want?

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: what plot command can i use on my graph

From: matlab_learner

Date: 25 Aug, 2010 17:42:27

Message: 11 of 12

Steven Lord:

I will go with the bottom graph. The one in red.


On Aug 25, 9:55 am, "Steven_Lord" <sl...@mathworks.com> wrote:
> "matlab_learner" <cib...@gmail.com> wrote in message
>
> news:7685c7ce-2d16-439c-911b-32aae4f3e3b4@p11g2000prf.googlegroups.com...
>
> > The plot it gives isn't right. The problem once again is
>
> > SOME OF THE DATA FOR THE TRADITIONAL MATERIAL on JUST ONE OF THE AXIS
> > IS A RANGE!!! IF YOU LOOKED AT WHAT MATLAB DID WITH THE CODE I PASTED
> > IT IS SUBTRACTING THE GIVEN BOUNDS (FOR EXAMPLE .043 minus .27) WHICH
> > IS NOT A RANGE!!!!!!  if it was that easy i won't b soliciting
> > assistance!!!
>
> > is it clearer now????
>
> Take a deep breath and calm down, please.
>
> Now, can you state specifically how you want the graph to appear for those
> materials?  Do you want some sort of errorbar plot where the errorbar covers
> the range of the values that material property can take?
>
> http://www.mathworks.com/access/helpdesk/help/techdoc/ref/errorbar.html
>
> If not, can you link to a picture that shows the type of graph that you
> want?
>
> --
> Steve Lord
> sl...@mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ:http://matlabwiki.mathworks.com/MATLAB_FAQ
> To contact Technical Support use the Contact Us link onhttp://www.mathworks.com

Subject: what plot command can i use on my graph

From: Steven_Lord

Date: 25 Aug, 2010 17:58:07

Message: 12 of 12



"matlab_learner" <cibeji@gmail.com> wrote in message
news:502c3165-a76b-4411-9cc3-a115fca339f5@q21g2000prm.googlegroups.com...
> Steven Lord:
>
> I will go with the bottom graph. The one in red.

[on the reference page for ERRORBAR.]

Okay, then run through the code associated with that example. Make sure you
understand what each line is doing to the sample data from count.dat. Then
adapt it to the data set that you have. You're probably going to want to
store the errorbar upper and lower limits in separate variables from the
data representing the center (main) property values, and use limits of 0 or
NaN for the limits on those material property values you know exactly.

If after you've tried that you're still having problems, show your full code
(including the code where you define the variables used in your ERRORBAR
call) and explain what problem you're having and someone may respond with a
suggestion on how to avoid that problem.

*snip*

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

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