Can someone Help me with basic program

Dear All,
I am really new to scilab and i am looking forward to basic code for one of the research papers here to do some research work. The formulas are as under and I need a code to understand how to input and how to get an output. Once the 4 equations are solved, i think I will be able to manipulate the things.

Hello, what do you mean by the “4 equations solved” ? Equations (1) to (4) are explicit parametric equations of a surface (parameters are \theta and \phi), so do you want to plot the surfaces ?

Yes I want to solve and plot surface. I need to understand how to put this equation in scilab and execute it …

Here is an example for equation (3):

a = 1;
b = 1/10;
T = 10;
theta = linspace(0,%pi,40);
phi = linspace(-atan(a/b),atan(a/b),40);
[theta,phi] = meshgrid(theta,phi);

x = b*sin(phi)+a*cos(theta-phi);
y = b*cos(phi)+a*sin(theta-phi);
z = T/(2*%pi)*phi;

clf
gcf().color_map=parulacolormap(128)
surf(x,y,z)
isoview

Thanks. Really appreciate it !
I wanted to know how to save it to a file and recall it back from a file in a scilab.
A link to help / guide page shall also suffice.

a = 1;
b = 1/10;
T = 10;
theta = linspace(0, %pi, 40);
phi = linspace(-atan(a/b), atan(a/b), 40);
[theta, phi] = meshgrid(theta, phi);

x = b * sin(phi) + a * cos(theta - phi);
y = b * cos(phi) + a * sin(theta - phi);
z = T / (2 * %pi) * phi;

% Save coordinates to a text file
fileID = mopen("coordinates.txt", "w");
mprintf(fileID, "X\tY\tZ\n");
for i = 1:size(x, 1)
    for j = 1:size(x, 2)
        mprintf(fileID, "%f\t%f\t%f\n", x(i, j), y(i, j), z(i, j));
    end
end
mclose(fileID);

% Plot the 3D surface
clf
gcf().color_map = parulacolormap(128);
surf(x, y, z);
isoview; 

some mistake in code, can someone assist

You can directly save the graphics itself

a = 1;
b = 1/10;
T = 10;
theta = linspace(0,%pi,40);
phi = linspace(-atan(a/b),atan(a/b),40);
[theta,phi] = meshgrid(theta,phi);

x = b*sin(phi)+a*cos(theta-phi);
y = b*cos(phi)+a*sin(theta-phi);
z = T/(2*%pi)*phi;

clf
gcf().color_map=parulacolormap(128)
surf(x,y,z)
isoview

xsave("helix.scg",0) // 0 is the number of the figure. By default the current figure is saved
scf(1); // open a new figure with number 1
xload("helix.scg"); // or xload("helix.scg",1) creates the new figure before loading the graph inside

Thanks So Much !
Another one question, I need Syntax to Solve The below equations This is the extension to the paper, and I am trying to find out a complete solution. Can you please guide and support. I need to mainly for (x-L)[b*cos(phi)…]=0 condition. How do I input it.

What are the unknowns, which variables are fixed ? Please stop posting out of context pieces of your paper if you want us to help. If the text is available freely please give an adress where it can be downloaded.

What I presume from equation (28) is that the last line is the implicit equation of the surface, whereas the first 3 lines are the parametric equations. Hence you just need to adapt the Scilab code which was posted previously.

S.

Xc yc zc are unknown, Alpha & L are fixed.

all others are fixed and connected to previous equations.
Solution yeilds pics as shown,
image

@mottelet Can I get your email id.
I have the code and paper ready, but later part of the code is creating issues which I am unable to resolve it. Can you please support me ?

Below is the link to download my code and paper. Can you point out where I could be wrong. Also, I feel i might be wrong on basic equation solving in scilab, due to manual errors.

WeTransfer - Send Large Files & Share Photos Online - Up to 2GB Free Download source code and paper

The authors of the paper say they have used Matlab. You should contact them directly and ask for their code, which will be very easy to adapt to Scilab.

S.

Yes, thanks, but we are unable to contact them.
So we thought to make a code for self using opensource scilab.
Do you know anyone professionally, or anyone here who can make a code for us in scilab ?

I already gave you ALL elements:

  1. The example code for equation (3)
  2. The remark about the algebraic equation after the parametric equations, which is a redundant one, as it is equivalent to the parametric equations (which are sufficient to draw the surface), considering page 4 of the paper which explains in equation (10) the coordinate change between x,y,z and x_c,y_c,z_c.

In the code you sent via WeTransfer you forgot the meshgrid call to transform the vectors of parameters values into matrices and you wrongly use plot to draw surfaces, although my example uses surf. And last, you try to plot values of the algebraical equations, which does not serve anything.

I repeat, you just have to adapt the code I gave to your other parametric surfaces.

S.

1 Like