help-octave
[Top][All Lists]

## Re: Code Problem

 From: Nicholas Jankowski Subject: Re: Code Problem Date: Wed, 19 Feb 2020 16:52:04 -0500

On Wed, Feb 19, 2020 at 4:48 PM Brett Green <address@hidden> wrote:

On Wed, Feb 19, 2020 at 4:38 PM Richard Schumacher <address@hidden> wrote:
Good afternoon, I cannot seem to figure out how to fix my parse errors for this code. Any suggestions? Attached are the formulas I am using. Please note that the theta is in DEGREES, so I used both cosd & sind.

Thank you

Richard

Code Below:

%Variables

%Crank Angle, Theta
%Bore, B
%Stroke, L
%Compression Ratio, r
%Connecting rod length to crank-arm length a, ratio R=1/a
%Area of Piston, Ap
%Crankshaft Rotational Speed, N [RPM]

%We are looking for Volume (theta),Area (theta), Piston Velocity Up (theta),
%First derivative of volume wrt theta (dV/d(theta)),
%First derivative of Area wrt theta, (dA/d(theta))

%Inputs

theta=15 %[degrees]
B = 14 %[inches]
L = 14 %[inches]
r = 9
R = 6
Ach = 231 %[inches^2]
Ap = 154 %[inches^2]
N = 1500 %[RPM]

%Equations

Vd= ((3.14159*(B^2))/4)*L  %this equation works

Vc=Vd/(r-1) %this equation works

V = Vc*{1+0.5(r-1)*[(R+(1-cosd(theta))-((R^2)-sind^2(theta))^0.5]}

A=Ach+Ap+((3.14159*B*L)/2)[(R+1)-cosd(theta)-(R^2-sind^2(theta))^0.5]

Up=(3.14159*L*N*sind(theta)(cosd(theta)))/((R^2-sind^2(theta))^(0.5)+1)

%Output

Please include errors when submitting to the mailing list.

The problem is the use of square brackets. Only parentheses should be used in equations like this - square brackets are used for defining arrays.

Yes, curly braces, square braces, and parentheses all mean very different things in Octave/Matlab syntax.  for general operation grouping,  just use parentheses. square brackets are for array definition, curly brackets are for 'cells' .