Hi, can you help me fix my code? How can I convert this to a matrix using if/while/for statements?
Mostra commenti meno recenti
format long G
MERfgh = [];
i = 1;
%for i=1:11
MERfgh(i,1) = MERfff(i,1);
for j=1:11
MERfgh(i,2) = MERfff(j,1);
i = i+1;
end
%end
MERfgh
I WANT IT TO LOOK LIKE THIS:

Risposte (2)
Consider the example:
% some data in a column vector
MERfff = (21:31).';
% rearrange it
[xx yy] = meshgrid(MERfff);
MERfgh = [xx(:) yy(:)]
1 Commento
Also consider this example using element-wise raise-to-power:
10.^(-1:1)
Use the power of MATLAB; it is, after all, MATrixLABoratory...
format short e; format compact
P=2; % power range -- use small number for demo so can see output...
x=10.^[-P:P].';
M=[kron(x,ones(size(x))) repmat(x,size(x))]
Categorie
Scopri di più su Logical in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!