[solved]Scilab: Plot in a loop

Need help with C, C++, perl, python, etc?

[solved]Scilab: Plot in a loop

Postby Lecram » 2015-12-13 11:29

hi guys,
I want to know how to plot in a loop. This is my code
Code: Select all
clc
clear all
for x=1:0.5:10
    y=x+1
    printf("\n the value of y:%f",y)
 plot(x,y)
end

the plot only shows the axes. This is my output.
Image
http://i.imgur.com/2mZQEhL.png
Last edited by Lecram on 2016-08-14 07:07, edited 5 times in total.
User avatar
Lecram
 
Posts: 92
Joined: 2009-06-03 08:54
Location: India

Re: Scilab: Plot in a loop

Postby dasein » 2015-12-13 13:54

Not pertinent to your problem, but pertinent to your post...

As a courtesy to folks who have metered/limited bandwidth, please thumbnail your images. Those bandwidth-guzzling fullscreen images add up fast.
User avatar
dasein
 
Posts: 7267
Joined: 2011-03-04 01:06
Location: Terra Incantationum

Re: Scilab: Plot in a loop

Postby Lecram » 2015-12-13 14:41

Thanks for the reminder dasein
User avatar
Lecram
 
Posts: 92
Joined: 2009-06-03 08:54
Location: India

Re: Scilab: Plot in a loop

Postby den4oman » 2016-04-12 12:07

Hi , i saw it's an old post but however
This is the solution to your problem:
/*
clear all
x=[] // Declare empty matrix
y=[] // Declare empty matrix
for i=1:0.5:100
x(1,i)=i // take the i-th column
y(1,i)=x(i)+1
plot(x,y) //plot them
end
*/

If you want to calculate something really big , you can make a "if" control statement which can take out some numbers from your matrices so it's light to plot.
Hope that helps ; )
den4oman
 
Posts: 13
Joined: 2016-04-07 22:35

Re: Scilab: Plot in a loop

Postby Lecram » 2016-08-14 07:07

Thanks it really works.
User avatar
Lecram
 
Posts: 92
Joined: 2009-06-03 08:54
Location: India


Return to Programming

Who is online

Users browsing this forum: No registered users and 4 guests

fashionable