Mapping Column Vector back into Temporary Array

Hi,
I have a column vector (temperature) storing 40 values which I would like to transfer into a temporary array, tempm.
The Array is initialised with zeros(6,12). I have been trying to use an example I have to help but in that case the array is NXN (5X5) whereas I have an N and an M, 6 and 12 respectivly and I can't work out how to write the code to reflect this. My best attempt so far is below, however the bottom line should be 0 to 2 in 0.2 intervals and the 12th vector column should be 0 to 1 ascending in 0.2 intervals:
xax = zeros(1,M+2);
yax = zeros(N+2,1);
for i=1:N+2,
xax(i) = (i-1)/(M/2);
yax(i)=(i-1)/(N+1);
tempm(i,M+2) = (i-1)/(M/2);
tempm(N+2,i) = (i-1)/(N+1);
end
Thanks in advance for any help. Please let me know if you require any more information or code.

7 Comments

Sorry, I forgot to attach a screenshot of my array in the original post
Can you post: your original array temp and what you'd like tempm to be? It's not clear to me where all of the pieces in the for-loop are coming from or what they goals are.
So this code maps my 40X1 colum vector back into my original grid of nodes as seen below.
I would then like to apply my boundary conditions to my array. My original grid lengths are y=1 and x=2, with 4 and 10 nodes in each direction respectively so I would like the code to calculate the node spacing and apply this to the arrary boundaries.
%solve equations
temperature = tmatrix\trhs;
% Generate an image of temperatures including boundary conditions
tempm = zeros(N+2, M+1);
for i=1:N
for j=1:M
eqno = M*(i-1)+j;
tempm(i+1,j+1) = temperature(eqno);
surf(tempm)
end
end
% Boundary condition values:
tempm(1,:) = 0;
tempm(:,1) = 0;
sorry 'temperature' is the 40X1 results vector and tempm is the array I have mapped to
You have 72 values in your array and 40 in your vector.
Please describe how you want to map those 40 values to your array.
Ok I have worked this out now, the code and description I provided had inaccuracies. Thank you for anyone who took a look at this and apologies for any confusion.

Answers (0)

This question is closed.

Asked:

on 3 Dec 2014

Closed:

on 20 Aug 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!