- Let data be your 6X3 matrix.
- Take x,Y and Z from the data. X = data(:,1) ; Y = data(:,2) ; Z = data(:,3) ;
- Define your formula: f= (X-0.33).^2+(Y-0.33).^2+(Z-0.33).^2 ;
- You got f, append it to the data.
6*3 matrix and put each value row wise in equation f(x,y,z)= [(X-0.33).^2+(Y-0.33).^2+(Z-0.33).^2] and calculate the answer and store that value as 4th column in matrix
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Pratik Anandpara
am 16 Dez. 2016
Beantwortet: Image Analyst
am 17 Dez. 2016
firstpop =
x y z f(x,y,z)
6 1 2
2 5 2
7 1 1
2 6 1
1 2 6
0 0 9
0 Kommentare
Akzeptierte Antwort
KSSV
am 16 Dez. 2016
What is there to do in your question? It is very easy and straight forward. I advice you to read MATLAB basics, it is very straight forward job.
0 Kommentare
Weitere Antworten (1)
Image Analyst
am 17 Dez. 2016
If a 3D array is wanted for f instead of a 1-D vector (it's hard to tell from your description), then you need to use meshgrid().
% x y z f(x,y,z)
firstpop =[...
6 1 2
2 5 2
7 1 1
2 6 1
1 2 6
0 0 9]
x = firstpop(:, 1);
y = firstpop(:, 2);
z = firstpop(:, 3);
% Get all possible combinations
[X, Y, Z] = meshgrid(x, y, z);
% Now compute the 3-D matrix:
f = (X-0.33).^2+(Y-0.33).^2+(Z-0.33).^2;
Now f is a 3D array instead of a 1-D array like in KSSV's solution.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!