Create a 4D matrix with specific range values
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Bruno Silva
il 29 Ago 2017
Risposto: Image Analyst
il 29 Ago 2017
I would like to create a 4D matrix with specific range values:
For the first dimension, values from [5 10 15 ... 200] so basically 5*[1:40]
For the second dimension, values from the list [8 10 20 25 40 50 100 200]
For the third dimension, values from [1 2 3 ... 10] so [1:10]
For the fourth dimension, values from [1 2 ... 50] that is [1:50]
When accessing a specific "value" of that matrix, I would like to be able to view these rages that I've set up for each dimension. For example: A(2,1,2,3) = [10 8 2 3] (in this case)
How can I do that?
Thank you.
4 Commenti
Image Analyst
il 29 Ago 2017
Modificato: Image Analyst
il 29 Ago 2017
No. You can't have a vector of 4 numbers at a particular location. You can just have a single number as James said. And you didn't even explain it - you just repeated what you said first. Let's say the "A" is a video, so we have row and column as the first two indexes, The red green or blue value as the third index, and frame number as the 4th index. So A(2,1,2,3) would be row 2, column1 of color channel #2 (blue) and you're looking at frame #3 (because the 4th index is 3). Now the blue value is one value -- it can't be a vector of 4 blue values. Please supply context as to what this 4-D array represents. When you send in indexes to A, what do those indexes represent?
Risposta accettata
Image Analyst
il 29 Ago 2017
You can store the error
In quadruple loop over all 4 parameters...
theActualValue = whatever(..........
thisError = SomeFunctionToComputeError(theActualValue, theExpectedTrueValue);
% Save error for this combination of parameters.
A(samplingRate, windowSize, numLayers, numNeurons) = thisError;
0 Commenti
Più risposte (1)
James Tursa
il 29 Ago 2017
Modificato: James Tursa
il 29 Ago 2017
Here is one way to do what you have asked, although I don't really know if this is the best way to go about coding the real problem you are trying to solve:
D1 = 5:5:200;
D2 = [8 10 20 25 40 50 100 200];
D3 = 1:10;
D4 = 1:50;
A = @(a,b,c,d) [D1(a) D2(b) D3(c) D4(d)]
Then, e.g.
>> A(2,1,2,3)
ans =
10 8 2 3
In this case, A is actually a function handle and not a 4D matrix. But it will yield the vector result you want when passed four inputs that are used to index into your "dimension" vectors.
0 Commenti
Vedere anche
Categorie
Scopri di più su Matrix Indexing in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!