How to display the output as table shown below?

1 visualización (últimos 30 días)
S Priya
S Priya el 24 de Ag. de 2021
Respondida: Kevin Holly el 24 de Ag. de 2021
z(:,:,1) =
0.4794 0.8776 0
0.0000 1.0000 0
-0.4794 0.8776 0
z(:,:,2) =
0.4794 0.8776 1.0000
0.0000 1.0000 1.0000
-0.4794 0.8776 1.0000
z(:,:,3) =
0.4794 0.8776 2.0000
0.0000 1.0000 2.0000
-0.4794 0.8776 2.0000
How can I display output as follows?
z=
Nodenumber(1) 0.4794 0.8776 0
Nodenumber(2) 0.0000 1.0000 0
Nodenumber(3) -0.4794 0.8776 0
Nodenumber(4) 0.4794 0.8776 1.0000
Nodenumber(5) 0.0000 1.0000 1.0000
Nodenumber(6) -0.4794 0.8776 1.0000
Nodenumber(7) 0.4794 0.8776 2.0000
Nodenumber(8) 0.0000 1.0000 2.0000
Nodenumber(9) -0.4794 0.8776 2.0000
  1 comentario
per isakson
per isakson el 24 de Ag. de 2021
Tags in this forum shall not have a leading "#" .
"display output as follows" By typing "z" in the command window you cannot get this output. There will be a lot of brackets.

Iniciar sesión para comentar.

Respuestas (2)

Wan Ji
Wan Ji el 24 de Ag. de 2021
You can use a table to achieve the output
Node = reshape(permute(z,[1,3,2]),numel(z)/size(z,2), size(z,2));
Nodenumber = char (num2str((1:size(a,1))'));
z = table(Nodenumber,Node)

Kevin Holly
Kevin Holly el 24 de Ag. de 2021
z(:,:,1) =[
0.4794 0.8776 0
0.0000 1.0000 0
-0.4794 0.8776 0];
z(:,:,2) =[
0.4794 0.8776 1.0000
0.0000 1.0000 1.0000
-0.4794 0.8776 1.0000];
z(:,:,3) =[
0.4794 0.8776 2.0000
0.0000 1.0000 2.0000
-0.4794 0.8776 2.0000];
%preallocate
Nodenumber = zeros(size(z,1)*size(z,2),size(z,3));
count =0;
for j = 1:size(z,3)
for i=1:size(z,1)
count = count +1;
Nodenumber(count,:) = z(i,:,j);
end
end
for ii = 1:size(z,1)*size(z,2)
output{ii} = ['Nodenumber(' num2str(ii) ') ' num2str(Nodenumber(ii,:))];
end
output'
ans = 9×1 cell array
{'Nodenumber(1) 0.4794 0.8776 0' } {'Nodenumber(2) 0 1 0' } {'Nodenumber(3) -0.4794 0.8776 0'} {'Nodenumber(4) 0.4794 0.8776 1' } {'Nodenumber(5) 0 1 1' } {'Nodenumber(6) -0.4794 0.8776 1'} {'Nodenumber(7) 0.4794 0.8776 2' } {'Nodenumber(8) 0 1 2' } {'Nodenumber(9) -0.4794 0.8776 2'}
I am unsure what you are looking for, so I created two different outputs.
Nodenumber(1,:)
Nodenumber(2,:)

Categorías

Más información sobre Signal Integrity Kits for Industry Standards en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by