Plotting data from a matrix: Showing shaded area on graph
Show older comments
Dear all,
I have the following situation:
- I have a solution, with both a certain weight percent of polymer, C_wt, and a certain molarity of salt, C_NaCl.
- I have made a function to find the total molarity of salt in the solution (since the polymer contains ions that are released in the solution). Here this important part is that the C_Cl give me the total Cl ions in the solution.
function [C_Cl] = counterionfunc(C_wt,C_NaCl, ps)
C_pdad = C_wt*10/ps.mw_pdad_monomer; %Concentration of monomer units: mol/L
C_Cl_pdad = C_pdad; %mol/L
C_Cl = C_Cl_pdad + C_NaCl; %mol/L
end
Now, I would like to create a figure, in which I show the NaCl molarity, C_NaCl, on the x axis, the weight percent of the polymer, C_wt, on the y-axis, and then shade the areas in which the total Cl ions in the solution are less than the solubity limit (4.38 M). I've made a small rough sketch below:

What I have tried so far, is below. First I make a struct to put in my values. Then I vectors for my C_wt (from 0 to 100 wt%) and C_NaCl (from 0 to 5 molar). Now when I put this into the function, I get a matrix C_Cl. Now I'm stuck... How do I continue? Your help would be much appreciated!
%constants put into a struct
ps = struct;
ps.mw_pdad_monomer = (8*12.01) + (16*1.01) + (1*14.007) + (1*35.45); %C8-H16-N-Cl:
ps.mw_pss_monomer = (8*12.01) + (7*1.01) + (16.00 *3) + (1*32.06) + (22.99); %C8-H7-O3-S-Na:
ps.mw_nacl = 58.44; %g/mol
% Max solubility is 25.6 g/100 ml of water at 20*C
sol_limit_molarity_nacl = ((25.6/ps.mw_nacl)/ 0.100); %is 4.38M
C_wt = [0:1:100]; %Weight percent of polymer
C_wt = C_wt'; %Transpose matrix
C_NaCl = [0:1:5];%molarity of NaCl
%Input values into function
[C_Cl] = counterionfunc(C_wt,C_NaCl, ps);
Accepted Answer
More Answers (0)
Categories
Find more on Language Fundamentals in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!