[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Matlab to Octave - problem wih the conversion
From: |
Juan Pablo Carbajal |
Subject: |
Re: Matlab to Octave - problem wih the conversion |
Date: |
Thu, 4 Aug 2016 15:16:39 +0200 |
On Thu, Aug 4, 2016 at 1:49 PM, Istan <address@hidden> wrote:
> Hi,
>
> Thank you for your answer and these informations.
>
> I m a new user of matlab and octave. I m sorry for the bad usage of the term
> Freeware, you are right. I didn't know the term of FOSS, the reason why I
> have used this inappropriate term.
>
>
> After I have posted, I have tried to find an over way to read my file, until
> this code on Octave :
>
>
> clear;
> dlmread('1.txt',' ');
> fid = [1,2,lines('400.txt'),5];
>
>
> the .txt is read and I can see my value. Unfortunately, the text file
> doesn't present always the same amount of space between each value, giving
> this kind of table (example) :
>
> x1 x2 x3 x4 x5 x6 x7 .... x
> 1 0 0 0 0 2 0 0
> 2 0 0 0 3 0 0 0
> 3 0 0 0 0 36 0 0
> 4 0 0 8 0 0 0 0
> 5 0 0 0 0 0 0 5
> 6 0 0 0 3 0 0 0
>
> In the end, I want to do 2 column :
>
> x1 x2
> 1 2
> 2 3
> 3 36
> 4 8
> 5 5
> 6 3
>
> to plot(x1,x2)
>
> I have posted too quickly yesterday, my ask lack of explanation.
>
> Cordially,
>
> Guillaum
>
>
>
> --
> View this message in context:
> http://octave.1599824.n4.nabble.com/Matlab-to-Octave-problem-wih-the-conversion-tp4678981p4679002.html
> Sent from the Octave - General mailing list archive at Nabble.com.
>
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/help-octave
Lets say you have an example.txt file like what you showed in your
mail (only the 7 first columns).
The following code reads the data
ncols = 7; # number of columns in file
nhead = 1; # number of header lines here: x1 x2 x3 x4 x5 x6 x7
data = txtread ("example.txt", "%d", "headerlines", nhead);
data = reshape (data, ncols, length(data) / ncols).'
ans =
1 0 0 0 0 2 0
2 0 0 0 3 0 0
3 0 0 0 0 36 0
4 0 0 8 0 0 0
5 0 0 0 0 0 0
6 0 0 0 3 0 0
then you can do
plot (data(:,1), data(:,2))
FOSS : https://en.wikipedia.org/wiki/Free_and_open-source_software
The Terms of Use of the "Matlab file central", which a place to
"share" the code, says in section 2.iii
(http://ch.mathworks.com/matlabcentral/termsofuse.html)
"Content that you submit must not directly compete with products
offered by MathWorks. Content submitted to File Exchange may only be
used with MathWorks products."
I would be surprised to read something similar in the terms of use (or
the user agreement) in the Matlab product or the function used to
generate the relevant code. Please do check and make no assumptions
about the rights you have on the code.
- Matlab to Octave - problem wih the conversion, Istan, 2016/08/03
- Re: Matlab to Octave - problem wih the conversion, Juan Pablo Carbajal, 2016/08/04
- Re: Matlab to Octave - problem wih the conversion, Sebastian Schöps, 2016/08/04
- Re: Matlab to Octave - problem wih the conversion, Istan, 2016/08/04
- Re: Matlab to Octave - problem wih the conversion,
Juan Pablo Carbajal <=
- Re: Matlab to Octave - problem wih the conversion, Juan Pablo Carbajal, 2016/08/04
- Re: Matlab to Octave - problem wih the conversion, Istan, 2016/08/04
- Re: Matlab to Octave - problem wih the conversion, Juan Pablo Carbajal, 2016/08/04
- Re: Matlab to Octave - problem wih the conversion, Istan, 2016/08/04
- Re: Matlab to Octave - problem wih the conversion, Juan Pablo Carbajal, 2016/08/04
- Re: Matlab to Octave - problem wih the conversion, Istan, 2016/08/05
- Re: Matlab to Octave - problem wih the conversion, Sebastian Schöps, 2016/08/04
- Re: Matlab to Octave - problem wih the conversion, Juan Pablo Carbajal, 2016/08/04
- Re: Matlab to Octave - problem wih the conversion, Sebastian Schöps, 2016/08/04