Help with Plotting a time and space dependent variable (Shrinking Core Model)
이전 댓글 표시
Hello MATLAB Community,
I hope everyone is doing great and staying safe and healthy. I am coding a time and space dependent property of a particle that is undergoing a chemical reaction. The reaction front basically moves from the outer most surface towards the center (Shrinking Core Model). I have succesfully coded it using nested FOR loops but I am having problems in extracting results and plotting them. I would be really grateful if someone can help me as this project report is due in a few days. The code is also attached.
- The figure below show the change in target variable as a function of radius, and each curve is for a specific time value. For example, 1 is the curve for time 1, 2 is the radius for time 2 and so on. I need help to convert this to a surface map with radiua as x variable, time as y variable and PCO2 as z variable.

2. The second thing I need help with is making a diagram. the sketch below shows what I have in mind. Right now my code can give the values of inner and outer radius at each time and also how PCO2 (the target variable) changes in the yellow region. I want to make this figure and display the values of PCO2 in the yellow region as acolor spectrum (high-red, low-blue). Any help would be greatly appreciated.
3. The last thing I need help with is putting a slider for time so I can automatically jump to the required time. Someting like an interactive graph of PCO2 vs. Radius witha time slider.
Once again THANKYOU for your attention and I would really appreciate any help.
The Code is attached
댓글 수: 7
darova
2020년 4월 25일
- Creating a surface
Just write each curve data into 2d matrix and use surf
- Diagram
Once you have your 2D matrices with CO2 and Radius you can convert them into X Y data
First scale the data
T1 = (T-minT)/(maxT-minT)*2*pi; % scale time between 0 .. 2*pi
R1 = (R_minR)/(maxR-minR)+0.5; % scale radius 0.5 .. 1.5
[X,Y] = pol2cart(T1,R1);
surf(X,Y,CO2)
Muhammad Farooq Zia
2020년 4월 25일
Muhammad Farooq Zia
2020년 4월 25일
Konstantinos Kakosimos
2020년 4월 26일
- as @Darova wrote, convert it to 2D matrix, + 1D for the value of each matrix element, and plot it with surf. You can initialize your matrix with the max dimensions expected using the initial values for your PCO2 i.e. PCO2=ones(ntime,nR)*PCO2_initial
- Your data in [1] as f(r,t) to make this plot you need to expand it with symmetry to f(r,theta,t) and then plot a POLAR contour. If you do not prefer the POLAR plot, transform your coordindates using POL2CART. Afterwards, select a fixed color for your outside and inside, of your torus, values to create the effect you want. I think, setting these values to NAN or selecting proper LIM could cause the effect you want.
- for the slider, I have used this https://www.mathworks.com/help/matlab/ref/uislider.html and the example described here https://www.mathworks.com/matlabcentral/answers/56236-how-to-constantly-update-a-plot-off-of-a-slider-being-pulled
Muhammad Farooq Zia
2020년 4월 26일
darova
2020년 4월 26일
Store values as (inside for loop)
R(1:m,t) = StrM1(:,1);
CO2(1:m,t) = StrM2(:,2);
Create time matrix as
T = repmat(1:n,size(R,1),1);
Muhammad Farooq Zia
2020년 4월 26일
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Chemistry에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!