very nice tutorial, could you please post all the documentation about the winio@ functions and all that stuff so we can customize more the plot, thanks in advance.
The documentation can be found online at the following parts of the Silverfrost website: silverfrost.com/ftn95-help/clearwinp/clearwin.aspx silverfrost.com/ftn95-help/clearwinp/formats/helpcontents1.aspx silverfrost.com/ftn95-help/clearwinp/library/helpcontents1.aspx silverfrost.com/ftn95-help/clearwinp/callback/helpcontents1.aspx
My interest is on a program that plots a given set of (xi,yi) points and the straight-line representing the linear regression (best linear fit). Do you have a such program?
This is a very useful class. Thank you very much.
Wow.. Thanks sir
Wow..... Fortran graphics man
thank you for the useful class sir, i have a question
how i do an animation to graph eich set time?
and thank you
very nice tutorial, could you please post all the documentation about the winio@ functions and all that stuff so we can customize more the plot, thanks in advance.
The documentation can be found online at the following parts of the Silverfrost website:
silverfrost.com/ftn95-help/clearwinp/clearwin.aspx
silverfrost.com/ftn95-help/clearwinp/formats/helpcontents1.aspx
silverfrost.com/ftn95-help/clearwinp/library/helpcontents1.aspx
silverfrost.com/ftn95-help/clearwinp/callback/helpcontents1.aspx
Could you, please, give a link for downloading this demo program? Thank you in advance. Fabio
The code is at the end of the video description above.
Ah, ok, I've found it. Thanks again, very useful.
My interest is on a program that plots a given set of (xi,yi) points and the straight-line representing the linear regression (best linear fit). Do you have a such program?
@@FabioLima-pc2dk Try the following. No guarantee it's error free!
program linreg_example
implicit none
integer, parameter :: dp = kind (0.1d0)
integer, parameter :: n = 10
real(dp) :: x(n), y(n)
! Define test data - this is a quadratic
x = (/0,1,2,3,4,5,6,7,8,9/)
y = x*x
! Do the analysis and plot the results
call pllinreg (x, y, n)
end program linreg_example
subroutine pllinreg (x, y, n)
use clrwin
implicit none
integer, parameter :: dp = kind (0.1d0)
integer, intent(in) :: n ! No of elements in x and y
real(dp),intent(in) :: x(n) ! X array
real(dp),intent(in) :: y(n) ! Y array
real(dp) m,b,r
real(dp) xlin(2),ylin(2)
integer iw, gx, gy
real(dp) nd, sumx, sumx2, sumxy, sumy, sumy2
! Do linear regression analysis on input data
sumx = sum(x)
sumx2 = sum(x * x)
sumxy = sum(x * y)
sumy = sum(y)
sumy2 = sum(y * y)
nd = dble(n)
m = (nd * sumxy - sumx * sumy) / (nd * sumx2 - sumx*sumx)
b = (sumy * sumx2 - sumx * sumxy) / (nd * sumx2 - sumx*sumx)
r = (sumxy - sumx * sumy / nd) / sqrt((sumx2 - sumx*sumx/nd) * (sumy2 - sumy*sumy/nd))
! Define two points on the linear line
xlin(1) = x(1)
xlin(2) = x(n)
ylin(1) = m*xlin(1) + b
ylin(2) = m*xlin(2) + b
! Plot results
iw = winio@('%mn[Exit]&','exit')
iw = winio@('%fn[Consolas]%ts%bf&',1.5d0)
call winop@('%pl[x_array,independent,n_graphs=2,width=2,smoothing=4,gridlines,frame]')
call winop@('%pl[Title="Linear Regression"]')
call winop@('%pl[link=curves,colour=blue,symbol=1]')
call winop@('%pl[link=lines,colour=grey,symbol=0]')
gx = 500
gy = 500
iw = winio@('%ff%nl%pv%pl&',gx,gy,[n,2],x,y,xlin,ylin)
iw = winio@('%ff%ts&',1.d0)
iw = winio@('%1tl&',30)
iw = winio@('%tc[black]%nl%cn linear slope%ta%`rf&',m)
iw = winio@('%nl%cn y-inercept %ta%`rf&',b)
iw = winio@('%nl%cn correlation coeff. %ta%`rf&',r)
iw = winio@('')
end subroutine pllinreg