Multiple lines on same graph - generated in a loop

Multiple lines on same graph - generated in a loop - Messages

#1 Posted: 6/18/2014 1:12:18 PM
ziopaper

ziopaper

1 likes in 13 posts.

Group: User

Hello,

I am trying to plot multiple lines on the same graph. I understood in the plot region I can insert the "multiple values" placeholder and add the different functions to be plotted there.

But what if I want 100 functions to be plotted? Do I have to add all of them manually in the placeholders, or does this possibility exists in Smath Studio?


In matlab I would do something like


x=vector between 0 and pi
for i:0; i<100; i++
{
for j=0; j< length(x); j++
{
matrix(i,j)=i*sin(x);
}
plot(x,matrix(i))
}

Thank you
Marco
#2 Posted: 6/18/2014 1:58:59 PM
Davide Carpi

Davide Carpi

1415 likes in 2872 posts.

Group: Moderator

Hello Marco,

This is easy. Just use a linear indexing assignment on a system (Look at the attachment).


Best regards,

Davide
Multiple plots.sm (9 KiB) downloaded 51 time(s).
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#3 Posted: 6/18/2014 2:20:01 PM
ziopaper

ziopaper

1 likes in 13 posts.

Group: User

grazieeeeee!!!
(thanks)

What if I want to plot with custom horizontal axis? that is building a specific horizontal axis vector?

what I am doing is clearly wrong

Marco
Multiple plots - wrong.sm (3 KiB) downloaded 37 time(s).
#4 Posted: 6/18/2014 2:22:28 PM
Davide Carpi

Davide Carpi

1415 likes in 2872 posts.

Group: Moderator

Di nulla (you're welcome)

Updated with domains and matrices.


Davide
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#5 Posted: 6/18/2014 2:28:33 PM
ziopaper

ziopaper

1 likes in 13 posts.

Group: User

just saw your editing...Thanks again
#6 Posted: 6/18/2014 2:31:35 PM
Davide Carpi

Davide Carpi

1415 likes in 2872 posts.

Group: Moderator

If you are interested on techniques to plot axis, you can see also this example made by oscampo
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#7 Posted: 6/18/2014 2:45:46 PM
ziopaper

ziopaper

1 likes in 13 posts.

Group: User

thanks, I had the bode plot example. Didn't have time to try to understand it yet.

btw, how did you insert the range? What is the horizontal line and how do I get it? (I tried with the fraction "/" ... fail!)
#8 Posted: 6/18/2014 2:52:36 PM
Davide Carpi

Davide Carpi

1415 likes in 2872 posts.

Group: Moderator

To have the range(2) function type range and press tab; to have he range(3)
function press the argument separator key inside a range(2) placeholder or select the range(3) function from the dynamic assistance.

To have the line(#) function type line and press tab, press the argument separator key to have more lines. You may also use the line button in the Programming palette on the right.

The number inside the parentheses is the arguments' number of the function (# means undefined)
2014-06-18 20_52_42-SMath Studio Desktop - [Page1_].png
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#9 Posted: 6/18/2014 2:55:08 PM
ziopaper

ziopaper

1 likes in 13 posts.

Group: User

sorry I meant the domain.
I was talking about the horizontal line under i*sin(x), where you wrote 0
#10 Posted: 6/18/2014 3:01:52 PM
Davide Carpi

Davide Carpi

1415 likes in 2872 posts.

Group: Moderator

Ahhh... the horizontal line is a simple fraction /

You can add the domain limiter:
- to the numerator, if you want to see a null value outside the domain;
- to the denominator, otherwise.

Booleans result is 0 for false and 1 for true, so [math eng]something/0[/math] is not visible.


The ternary boolean operator under the line is part of the Functions' Extension plugin, following the link in the attachments of the first post you can see the syntax (in the example above I've used ltlt and tab)
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#11 Posted: 6/18/2014 3:24:03 PM
ziopaper

ziopaper

1 likes in 13 posts.

Group: User

ok thanks again.

I am missing something.

If I type at the denominator
0it has no effect. Graph is plotted over the entire region.
if I copy from your original file 0Is there anything special the way I am supposed to write it??
Multiple plots - wrong2.sm (6 KiB) downloaded 39 time(s).
#12 Posted: 6/18/2014 3:27:23 PM
ziopaper

ziopaper

1 likes in 13 posts.

Group: User

ltlt!!!

Thank you!
#13 Posted: 6/18/2014 5:34:52 PM
Davide Carpi

Davide Carpi

1415 likes in 2872 posts.

Group: Moderator

Yes

because when you type < < you obtain [math eng]#<#<#[/math] that seems a ternary operator but is just a boolean less nested inside another boolean less; using parentheses indeed is [math eng]((#<#)<#)[/math], so in the end you have [math eng]((0
Without plugins booleans AND/OR are needed, as shown in my first post: [math eng](0
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#14 Posted: 6/18/2014 6:39:37 PM
ziopaper

ziopaper

1 likes in 13 posts.

Group: User

I swear I tried to thank you with the THANK button but I get an error, so Thank you!

I had the plugin without even knowing why, that is where my confusion comes from. Fantastic stuff.
  • New Posts New Posts
  • No New Posts No New Posts