How to plot coordinates
Mostra commenti meno recenti
Hi everyone, I am relatively new to MATLAB and would like assistance. I am trying to get plot the graph from the results achieved from my while loop but I am unable to get coordinates plot. Figure would show a blank graph. . Thank you so much
This is my code
function Salty= ROC(Vo,Vin,Vout,Cin)
Vo= input('Please enter the original volume liquid in tank:'); %%80L
Vin= input('Please enter the rate of solution in:'); %%8l/m
Vout= input('Please enter the rate of solution out:'); %%12/m
Cin= input('Please enter concentration of salt inlet:'); %%0.25
Vt(1)=Vo;%original volume of tank at t=1
i=2;
while Vt(i-1)>0
Vt(i)=Vt(i-1)+(Vin-Vout); %%Volume of tank=previous vol.+(IN - OUT) (Kg/L)
Min = Vin*Cin; %%Rate of mass of salt in(kg/min)=Volume in(L/min)*Concentration of salt in(kg/L)
Cout(i-1) = Min/Vt(i-1); %%Rate of change of salt out(kg/L) = Mass of salt in tank(kg/min) / Volume of solution in tank at any given time(L/min)
Mout(i-1)= Vout*Cout(i-1); %%Rate of mass out at any given time(kg/min)=Volume of tank at any given time*Concentration of salt out(kg/L)
Mt(i-1)= Min-Mout(i-1); %%Rate of mass in tank at any given in time(kg/min)=Mass of salt in-mass of salt out
formatspec='\n Volume of tank at time = %d mins is %d \n';
fprintf(formatspec,(i-1),Vt(i-1))
formatspec='\n Concentration of salt in the tank at time = %d mins is %.5f \n';
fprintf(formatspec,(i-1),Cout(i-1))
formatspec='\n Rate of mass of salt out at time = %d mins is %.5f \n';
fprintf(formatspec,(i-1),Mout(i-1))
formatspec='\n Rate of change of salt in the tank at time = %d mins is %.5f \n ';
fprintf(formatspec,(i-1),Mt(i-1))
plot(i,Mt(i-1),'-');
hold on
xlabel('T (mins)')
ylabel('Rate of change of salt (kg)')
title('Rate of change of salt against time')
if (Mt(i-1)<=0)
break
else
i=i+1;
end
end
hold off
1 Commento
Adam
il 20 Feb 2018
Do you need to be plotting in the loop? It would be a lot simpler to just plot your Mt vector once after the loop has finished.
Risposte (0)
Categorie
Scopri di più su Region and Image Properties in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!