The situation is such

There are such methods, where T is an input parameter that is entered from the keyboard (for example, T = 4)

public:static double fn(double T,double x) { if (x>=0) return T; else if(x<0) return 0; } public: void drawfunc(double T) { double xmin = -5; double xmax = 10; for(double x = xmin;x<xmax;x+=0.01) { chart1->Series["Series1"]->Points->AddXY(x,fn(T,x)); } } 

They draw this graph of the function.

enter image description here

But it is necessary that the method be with one parameter and draw as well as with 2 parameters. However, if I do it with one parameter, and I make the 2nd variable a local variable.

 public:static double heviside(double T) { double x=0; if ( x>=0) return T; else if(x<0) return 0; } public:void draw(double U,double T) { double xmin=-5; double xmax=10; for(double x=xmin;x<xmax;x+=0.01) chart1->Series["Line"]->Points->AddXY(x,heviside(T)); } 

That function graph is drawn this way. enter image description here

QUESTION!

How can I make the function draw the 1st graph but with the 1st parameter of the function fn (double T)?

    1 answer 1

    No The parameter x cannot be constant if you want the chart not to be a straight line.

    In the second version you have this:

     static double heviside(double T) { double x=0; // x - константа и равна 0 if(x>=0) // это условие всегда выполняется return T; // поэтому всегда выполняется только эта ветка else if(x<0) return 0; } public:void draw(double U,double T) { double xmin=-5; double xmax=10; for(double x=xmin; x<xmax; x+=0.01) chart1->Series["Line"]->Points->AddXY(x, heviside(T)); // вы взываете hevisible в цикле, при этом T // тоже не меняется, в итоге вы заполняете график // одними и теми же числами } 
    • Yes, yes, T does not change, because this is the coordinate from which the continuation of the graph of a single function will be. I have it as it was for example 4 and it remains to her as this is the coordinate from which the schedule changes. In the 1st case where 2 parameters are there, too, T does not change, but everything is built, but there is 2nd parameter x, which helps in changing the graph. - beginner