I have been trying to make a simple program that has you input the constants from a set of equations so that you dont have to write the full fromatting of the matrices each time. It works in chunks but when I put it together it says "Illegal use of reserved keyword "elseif"" I checked around and it seems you should be able to use multiple elseifs if you need to. If i use one elseif it is fine but once i add the second it wont work.
The code:
dim=input('How many equations' ); if dim>7 A=input('enter constants in matrix form' ); b=input('enter constants in matrix form' ); elseif dim==7 A=[input('E1 Insert first constant' ) input('E1 Insert second constant' ) input('E1 Insert third constant' ) input('E1 Insert fourth constant' ) input('E1 Insert fifth constant' ) input('E1 Insert sixth constant' ) input('E1 Insert seventh constant' );input('E2 Insert first constant' ) input('E2 Insert second constant' ) input('E2 Insert third constant' ) input('E2 Insert fourth constant' ) input('E2 Insert fifth constant' ) input('E2 Insert sixth constant' ) input('E2 Insert seventh constant' );input('E3 Insert first constant' ) input('E3 Insert second constant' ) input('E3 Insert third constant' ) input('E3 Insert fourth constant' ) input('E3 Insert fifth constant' ) input('E3 Insert sixth constant' ) input('E3 Insert seventh constant' );input('E4 Insert first constant' ) input('E4 Insert second constant' ) input('E4 Insert third constant' ) input('E4 Insert fourth constant' ) input('E4 Insert fifth constant' ) input('E4 Insert sixth constant' ) input('E4 Insert seventh constant' );input('E5 Insert first constant' ) input('E5 Insert second constant' ) input('E5 Insert third constant' ) input('E5 Insert fourth constant' ) input('E5 Insert fifth constant' ) input('E5 Insert sixth constant' ) input('E5 Insert seventh constant' );input('E6 Insert first constant' ) input('E6 Insert second constant' ) input('E6 Insert third constant' ) input('E6 Insert fourth constant' ) input('E6 Insert fifth constant' ) input('E6 Insert sixth constant' ) input('E6 Insert seventh constant' );input('E7 Insert first constant' ) input('E7 Insert second constant' ) input('E7 Insert third constant' ) input('E7 Insert fourth constant' ) input('E7 Insert fifth constant' ) input('E7 Insert sixth constant' ) input('E7 Insert seventh constant' )] b=[input('First answer' );input('Second answer' );input('Third answer' );input('Fourth answer' );input('Fifth answer' );input('Sixth answer' );input('Seventh answer' ); elseif dim==6 A=[input('E1 Insert first constant' ) input('E1 Insert second constant' ) input('E1 Insert third constant' ) input('E1 Insert fourth constant' ) input('E1 Insert fifth constant' ) input('E1 Insert sixth constant' );input('E2 Insert first constant' ) input('E2 Insert second constant' ) input('E2 Insert third constant' ) input('E2 Insert fourth constant' ) input('E2 Insert fifth constant' ) input('E2 Insert sixth constant' ) ;input('E3 Insert first constant' ) input('E3 Insert second constant' ) input('E3 Insert third constant' ) input('E3 Insert fourth constant' ) input('E3 Insert fifth constant' ) input('E3 Insert sixth constant' ) ;input('E4 Insert first constant' ) input('E4 Insert second constant' ) input('E4 Insert third constant' ) input('E4 Insert fourth constant' ) input('E4 Insert fifth constant' ) input('E4 Insert sixth constant' );input('E5 Insert first constant' ) input('E5 Insert second constant' ) input('E5 Insert third constant' ) input('E5 Insert fourth constant' ) input('E5 Insert fifth constant' ) input('E5 Insert sixth constant' );input('E6 Insert first constant' ) input('E6 Insert second constant' ) input('E6 Insert third constant' ) input('E6 Insert fourth constant' ) input('E6 Insert fifth constant' ) input('E6 Insert sixth constant' )] b=[input('First answer' );input('Second answer' );input('Third answer' );input('Fourth answer' );input('Fifth answer' );input('Sixth answer' )] elseif dim==5 A=[input('E1 Insert first constant' ) input('E1 Insert second constant' ) input('E1 Insert third constant' ) input('E1 Insert fourth constant' ) input('E1 Insert fifth constant' );input('E2 Insert first constant' ) input('E2 Insert second constant' ) input('E2 Insert third constant' ) input('E2 Insert fourth constant' ) input('E2 Insert fifth constant' );input('E3 Insert first constant' ) input('E3 Insert second constant' ) input('E3 Insert third constant' ) input('E3 Insert fourth constant' ) input('E3 Insert fifth constant' );input('E4 Insert first constant' ) input('E4 Insert second constant' ) input('E4 Insert third constant' ) input('E4 Insert fourth constant' ) input('E4 Insert fifth constant' );input('E5 Insert first constant' ) input('E5 Insert second constant' ) input('E5 Insert third constant' ) input('E5 Insert fourth constant' ) input('E5 Insert fifth constant' )] b=[input('First answer' );input('Second answer' );input('Third answer' );input('Fourth answer' );input('Fifth answer' ); elseif dim==4 A=[input('E1 Insert first constant' ) input('E1 Insert second constant' ) input('E1 Insert third constant' ) input('E1 Insert fourth constant' );input('E2 Insert first constant' ) input('E2 Insert second constant' ) input('E2 Insert third constant' ) input('E2 Insert fourth constant' );input('E3 Insert first constant' ) input('E3 Insert second constant' ) input('E3 Insert third constant' ) input('E3 Insert fourth constant' );input('E4 Insert first constant' ) input('E4 Insert second constant' ) input('E4 Insert third constant' ) input('E4 Insert fourth constant' )] b=[input('First answer' );input('Second answer' );input('Third answer' );input('Fourth answer' )] elseif dim==3 A=[input('E1 Insert first constant' ) input('E1 Insert second constant' ) input('E1 Insert third constant' );input('E2 Insert first constant' ) input('E2 Insert second constant' ) input('E2 Insert third constant' );input('E3 Insert first constant' ) input('E3 Insert second constant' ) input('E3 Insert third constant' )] b=[input('First answer' );input('Second answer' );input('Third answer' ); elseif dim==2 A=[input('E1 Insert first constant' ) input('E1 Insert second constant' );input('E2 Insert first constant' ) input('E2 Insert second constant' )] b=[input('First answer' );input('Second answer' )] else end
Best Answer