Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for i=elements+1 %this for loop will create extra row(s) in matrix A
- if col==elements+1 %if col is equal to elements+1,
- A(i,:)=0; %row element+1 is all zeros
- A(i,j)=1; %except column j (last column) is equal to 1
- else %if col is not equal to elements+1
- for j=1:1:n_react+n_prod %this for loop ask for charge in all molecules in the equation
- text6=sprintf('For %s, please identify its charge: ',formula{1,j}); %ask the user to enter the charge
- if j<=n_react %if number of loop is less than n_react, the input will be stored in matrix A as a positive number
- A(i,j)=input(text6);
- else %if number of loop is not less than n_react, the input will be stored in matrix A as a negative number
- A(i,j)=-input(text6);
- end
- end
- end
- for col==elements+2 %create one more row
- A(i,:)=0; %row i is all zeros
- A(i,j)=1; %except column j is 1
- end
- end
- end
- disp(A)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement