Re: Using the Prime to solve for eigenvalues Message #7 Posted by Eddie W. Shore on 25 Oct 2013, 9:25 a.m., in response to message #6 by Michael de Estrada
It is not the easiest working with symbolic objects in Prime Programming. What I did was make a temporary object for DET(M9 - 'X'*M8) and then called up the zeros function to solve for 'X'. In programming (and in Home Mode), the CAS. must precede any CAS operation.
I chose zeros instead of solve, since CAS.zeros works in home mode, and CAS.solve doesn't do as well.
One more point: I suggest modifying input strings to make program clarify which mass and spring to ask for (Mass 1, Mass 2, etc.).
Program:
EXPORT Frequencies()
BEGIN
LOCAL I,J,N,X,temp;
// Updated 10-25-2013
INPUT(N,"NDOF","N =","Enter N",0);
M7:=MAKEMAT(0,N);
M8:=MAKEMAT(0,N,N);
M9:=MAKEMAT(0,N,N);
FOR I FROM 1 TO N DO
// Modified Input Strings
INPUT(X,"Mass "+I,"Mass "+I+" =","Enter Mass",0);
M8(I,I):=X
END;
FOR I FROM 1 TO N DO
INPUT(X,"Spring "+I,"Spring "+I+" =","Enter Spring",0);
M7(I):=X
END;
FOR I FROM 1 TO N DO
FOR J FROM 1 TO N DO
IF I == J AND I < N THEN M9(I,J):=M7(I)+M7(I+1)
END;
IF I == J-1 THEN M9(I,J):=-M7(J)
END;
IF I == J+1 THEN M9(I,J):=-M7(I)
END;
END;
END;
M9(N,N):=M7(N);
// Some symbolic manipulation
temp:=DET(M9-'X'*M8);
M7:=CAS.zeros(temp);
PRINT("Frequencies = "+sqrt(M7)/(2*pi));
END;
Edited: 25 Oct 2013, 9:26 a.m.
|