Advertisement
Guest User

ช่วยเลาด้วย

a guest
Apr 20th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. for i=elements+1 %this for loop will create extra row(s) in matrix A
  2. if col==elements+1 %if col is equal to elements+1,
  3. A(i,:)=0; %row element+1 is all zeros
  4. A(i,j)=1; %except column j (last column) is equal to 1
  5. else %if col is not equal to elements+1
  6.  
  7. for j=1:1:n_react+n_prod %this for loop ask for charge in all molecules in the equation
  8. text6=sprintf('For %s, please identify its charge: ',formula{1,j}); %ask the user to enter the charge
  9. 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
  10. A(i,j)=input(text6);
  11. else %if number of loop is not less than n_react, the input will be stored in matrix A as a negative number
  12. A(i,j)=-input(text6);
  13. end
  14. end
  15. end
  16. for col==elements+2 %create one more row
  17. A(i,:)=0; %row i is all zeros
  18. A(i,j)=1; %except column j is 1
  19. end
  20. end
  21. end
  22. disp(A)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement