[Top][All Lists]

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

Re: xlsx processing

From: Steph Bredenhann
Subject: Re: xlsx processing
Date: Mon, 16 Mar 2020 18:54:37 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1

On 2020/03/16 14:10, mrodrig via Help-octave wrote:
I have worked a little more and I found this way to do it but I do not know
if it is the best
data.xlsx <>
clear all
pkg load io

[data_v, title_v]=xlsread("data.xlsx");
[rows, columns] = size(data_v)
for i=1:columns
     FileName=sprintf("%s.txt",[title_v{1,i}, "_", title_v{2,i},
     save (sprintf (FileName, i), "v")

Sent from:

I am not an Octave expert at all but I do read a lot data from xlsx files, I have included one of my implementations and as you can see I have the same dataset in a xlsx spreadsheet with different sheets. After reading I cast the data into the respective place holders. So, what I see with your data is that the alternating data rows can be problematic, can't you store A, B, C in different sheets and then read separately?

And I do everything in functions then local variables being duplicated is not a problem.

And, lastly, I work in Linux, you can do

nano .octaverc

and add the following to the file and save it in you home directory. A similar procedure is available for Windows.

pkg load io
pkg load statistics
pkg load optim

You can add the packages that you use regularly.

I hope that my contribution will also solicit comments from experts so that I can improve my own procedures!

function [ T, delta, Freq, G, G1, G2, Defl, Torque ]...
    = fn_read_MasterCurve_Unaged_data( NoFreq, NoTemps, Fname, SheetName )

%Read the creep and recovery experimental data
% Data in order:
%    1.  No
%    2.  Temp [�C]
%    3.  Phase angle [�]
%    3.  Freq [Hz]
%    6.  Complex modulus [kPa]
%    4.  Storage modulus [kPa]
%    5.  Loss modulus [kPa]
%    6.  Deflection angle [deg]
%    7.  Torque [uNm]

    datMC = xlsread (Fname,SheetName, [], 'OCT');

    T(1:NoTemps,1:NoFreq) = 0;
    delta(1:NoTemps,1:NoFreq) = 0;
    Freq(1:NoTemps,1:NoFreq) = 0;
    G(1:6,1:NoFreq) = 0;
    G1(1:NoTemps,1:NoFreq) = 0;
    G2(1:NoTemps,1:NoFreq) = 0;
    Defl(1:NoTemps,1:NoFreq) = 0;
    Torque(1:NoTemps,1:NoFreq) = 0;

    L1 = 1;
    L2 = L1+NoFreq-1;
    for iT = 1:NoTemps
        T(iT,1:NoFreq) = datMC(L1:L2,2);
        delta(iT,1:NoFreq) = datMC(L1:L2,3);
        Freq(iT,1:NoFreq) = datMC(L1:L2,4);
        G(iT,1:NoFreq) = datMC(L1:L2,5);
        G1(iT,1:NoFreq) = datMC(L1:L2,6);
        G2(iT,1:NoFreq) = datMC(L1:L2,7);
        Defl(iT,1:NoFreq) = datMC(L1:L2,8);
        Torque(iT,1:NoFreq) = datMC(L1:L2,9);
        %disp(sprintf('iT = %d  L1 = %d  L2 = %d',iT,L1,L2));
        L1 = L2+1;
        L2 = L2+NoFreq;


reply via email to

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