help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: eliminte "ans" and print file as is on the screen


From: Marco Atzeri
Subject: Re: eliminte "ans" and print file as is on the screen
Date: Thu, 10 Jan 2019 03:58:07 -0800
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0

Am 1/10/2019 um 3:05 AM schrieb eugenia:
Hi!
since a few days I am trying to plot something. I think I found a way but I
need to print a file with the same format I see on the screen but I need to
eliminate "ans".
I have a variable CHIS1.
disp(CHIS1(1,:,:))
ans(:,:,1) =

    3.3208e-04   3.6136e-04   3.4397e-04   3.2282e-04   3.0488e-04
3.5576e-04

ans(:,:,2) =

    7.8157e-04   6.4418e-04   6.8477e-04   5.5001e-04   4.8390e-04
4.0325e-04

ans(:,:,3) =

3.9184e-04   2.5231e-04   4.5585e-04   3.9979e-04   3.8978e-04   0.0000e+00
.
..

An I want to print this in a file (without "ans")  with this format:

    3.3208e-04   3.6136e-04   3.4397e-04   3.2282e-04   3.0488e-04
3.5576e-04
    7.8157e-04   6.4418e-04   6.8477e-04   5.5001e-04   4.8390e-04
4.0325e-04
   3.9184e-04   2.5231e-04   4.5585e-04   3.9979e-04   3.8978e-04
0.0000e+00


I tried to apply many instructions on the web but they didn't work... Can
somebody help me?

Regards,
Marie Eugenia

Hi Marie Eugenia,

look at reshape on
https://octave.org/doc/interpreter/Rearranging-Matrices.html#Rearranging-Matrices

as it seems you want to convert from a 3 indices matrix
to a 2 indices matrix , or a portion of it

a=rand(2,3,4)
a =

ans(:,:,1) =

   0.359352   0.036676   0.803829
   0.552612   0.733710   0.406368

ans(:,:,2) =

   0.82129   0.80905   0.81632
   0.55000   0.18838   0.96678

ans(:,:,3) =

   0.77684   0.39601   0.54564
   0.29402   0.12709   0.55232

ans(:,:,4) =

   0.477781   0.044654   0.720754
   0.562815   0.571051   0.174492

octave:33> b=reshape(a,2,3*4)
b =

 Columns 1 through 7:

   0.359352   0.036676   0.803829   0.821287   0.809049   0.816319
0.776840
   0.552612   0.733710   0.406368   0.549999   0.188378   0.966778
0.294024

 Columns 8 through 12:

   0.396012   0.545636   0.477781   0.044654   0.720754
   0.127094   0.552318   0.562815   0.571051   0.174492

octave:34> size(b)
ans =

    2   12

octave:35> b=reshape(a(1,:,:),3,4)
b =

   0.359352   0.821287   0.776840   0.477781
   0.036676   0.809049   0.396012   0.044654
   0.803829   0.816319   0.545636   0.720754

octave:36> size(b)
ans =

   3   4









---
Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft.
https://www.avast.com/antivirus




reply via email to

[Prev in Thread] Current Thread [Next in Thread]