Assign parameters to an array of zeros, ones, twos and threes

Hi,
I have a matrix which is filled with ones, zeros, twos and threes. I want to populate these coefficients with assigned input parameters such that the zero elements within the matrix will have a corresponding A,B and C and subsequently the twos, threes and ones will have different values for A, B and C.
To put it more into perspective.
I am solving for a 1D diffusion equation where the temperature outputs will have temperature dependent variables assigned to each from an interval from 100-150, 151-200, 201-250 and 251-300, attached is 123.png which illustrates the temperature output before adding any temperature dependent variables.
In utilising bsxfun I am able to establish a secondary matrix which can evaluate each of the zeros, ones, twos and threes as shown in bsxfun.png, to which I am attempting to assign the temperature dependent variables.
If I haven't been clear on anything please let me know and thank you for reading,
Snipe.

 Risposta accettata

Stephen23
Stephen23 il 5 Ago 2016
Modificato: Stephen23 il 5 Ago 2016
Just use 1+Z (from my answer to your last question) as indices:
Z = [...
0 1 1 1 1 1 1 2 2 2 2 2 2 3 3 3 3
0 1 1 1 1 1 1 2 2 2 2 2 2 2 3 3 3
0 1 1 1 1 1 1 1 2 2 2 2 2 2 2 3 3
0 1 1 1 1 1 1 1 2 2 2 2 2 2 2 3 3];
Avec = [1.2,3.4,5.6,7.8]; % four A parameters
Amat = Avec(1+Z)
And the same for the B and C parameters.

Più risposte (0)

Categorie

Community Treasure Hunt

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

Start Hunting!

Translated by