Creating an Image matrix (5x10) from a 5x100 matrix
Show older comments
clc
clear all
I = 1;
b0 = I; ep0 = 0; c0=0; a10=0;
tMax=30; dt=0.1;
timeVector = 0:dt:tMax; nIterations = length(timeVector);
conc_blood = [];
conc_endo = [];
conc_liver = [];
%euler
b(1) = b0;
ep(1)= ep0;
c(1) = c0;
for i = 1:100
ra12_1(i) = rand; ia12_1 = 0.3;
if ra12_1(i)>=ia12_1
a12_1(i)=0.5;
else
a12_1(i) = 0;
end
ra12_2(i) = rand; ia12_2 = 0.3;
if ra12_2(i)>=ia12_2
a12_2(i)=0.5;
else
a12_2(i) = 0;
end
ra23_1(i) = rand; ia23_1=0.5;
if ra23_1(i) >= ia23_1
a23_1(i) = ia23_1;
else
a23_1(i) = 0;
end
ra23_2(i) = rand; ia23_2=0.5;
if ra23_2(i) >= ia23_2
a23_2(i) = ia23_2;
else
a23_2(i) = 0;
end
ra21_1(i) = rand; ia21_1=0.5;
if ra21_1(i) >= ia21_1
a21_1(i) = ia21_1;
else
a21_1(i) = 0;
end
ra21_2(i) = rand; ia21_2=0.5;
if ra21_2(i) >= ia21_2
a21_2(i) = ia21_2;
else
a21_2(i) = 0;
end
c1(1) = c0;
ep1(1) = ep0;
b(1) = b0;
ep2(1)= ep0;
c2(1) = c0;
c1(i+1)=c1(i)+dt*liver1(timeVector(i),a23_1(i),ep1(i));
ep1(i+1)=ep1(i)+dt*endo1(timeVector(i),a12_1(i),ep1(i),a21_1(i),b(i),a23_1(i));
b(i+1)=b(i)+dt*blood(timeVector(i), a10, a12_1(i), a12_2(i), b(i), a21_1(i), a21_2(i), ep1(i), ep2(i));
ep2(i+1)=ep2(i)+dt*endo2(timeVector(i),a12_2(i),ep2(i),a21_2(i),b(i),a23_2(i));
c2(i+1)=c2(i)+dt*liver2(timeVector(i),a23_2(i),ep2(i))
A = [c1; ep1; b; ep2; c2];
imagesc(A)
colormap winter
colorbar
end
Hello everyone!
I am trying to create an image matrix from the code above. I have created a 5x100 image matrix which contains all of the values recieved. However, intead of receiving this monstrosity of an image I would like a 5x10 matrix to get updated with the values as the code is running. Basically I would like to push a 5x10 matrix through the bigger matrix and (keeping the size 5x10) running along the 'gradient' of the bigger matrix. This I would like to be done with a .1 second pause for every update and display those with a colormap (which I can do later so this is not crucial atm). Does anyone know how to do this or are able to help, every thought is appreciated.
Thanks in beforehand!
Answers (2)
KALYAN ACHARJYA
on 18 Dec 2020
Edited: KALYAN ACHARJYA
on 18 Dec 2020
"I have created a 5x100 image matrix which contains all of the values recieved. However, intead of receiving this monstrosity of an image I would like a 5x10 matrix to get updated with the values as the code is running. Basically I would like to push a 5x10 matrix through the bigger matrix"
I have answered this based on the description in your question, hope I understood it correctly. eg.
data_test=[];
for c=1:10
data=rand(5,10); %Random data 5x10
data_test=[data_test,data]; % Horizantal concatenation with previous data
imagesc(data_test)
%colormap winter
colorbar
pause(1);
clf;
end
"keeping the size 5x10"
For the resultant matrix?
1 Comment
William Larsson
on 18 Dec 2020
Image Analyst
on 18 Dec 2020
0 votes
Why is it a monstrosity? 5x100 is still very very small (much smaller than a typical digital image for example).
I didn't delve into your question in detail but maybe rem() or mod() is what you want. With that you can reset the columns beyond 5 to the 1-5 range.
Categories
Find more on Creating and Concatenating Matrices 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!