Answered

Extract data from sequentially named tables

"So after loading the files, I am left with tables I cannot call, because they are named sequentially..." Actually there is a r...

Extract data from sequentially named tables

"So after loading the files, I am left with tables I cannot call, because they are named sequentially..." Actually there is a r...

17 dagen ago | 1

Answered

How to import data from a .txt file with semicolons

Because you did not upload a sample file I had to create my own (attached). format short G mat = readmatrix('test.txt', 'Delim...

How to import data from a .txt file with semicolons

Because you did not upload a sample file I had to create my own (attached). format short G mat = readmatrix('test.txt', 'Delim...

17 dagen ago | 0

Answered

Different "kind" of variable

typ = ["oats","milk","water"] mat = [66,12,0;10,8,0;7,8,0] inp = ["milk","oats"]; qty = [2,0.5]; [~,idx] = ismember(inp,t...

Different "kind" of variable

typ = ["oats","milk","water"] mat = [66,12,0;10,8,0;7,8,0] inp = ["milk","oats"]; qty = [2,0.5]; [~,idx] = ismember(inp,t...

17 dagen ago | 0

Answered

How to flip an array without using the flip command ?

F = [-0.5,4.5,-2.0,3.6,8.5,7.3,2.5,1.2,6.5] P = F(end:-1:1)

How to flip an array without using the flip command ?

F = [-0.5,4.5,-2.0,3.6,8.5,7.3,2.5,1.2,6.5] P = F(end:-1:1)

17 dagen ago | 0

| accepted

Answered

Problem with ploting exp function

"I think there is a problem with .*exp(x-y)" I doubt that. Did you look at the domains and ranges that you are plotting? Your ...

Problem with ploting exp function

"I think there is a problem with .*exp(x-y)" I doubt that. Did you look at the domains and ranges that you are plotting? Your ...

17 dagen ago | 1

| accepted

Answered

How to SUMIF similar to Excel

"Not sure where this is going wrong." Reinventing the wheel by writing lots of loops, and ignoring the inbuilt tools. dt = dat...

How to SUMIF similar to Excel

"Not sure where this is going wrong." Reinventing the wheel by writing lots of loops, and ignoring the inbuilt tools. dt = dat...

17 dagen ago | 0

Answered

i have a code that isnt running through all the if statements

The problem is how you have used IF and ELSIF. All character codes in the text 'skating' are all non-zero, so if ('skating') ...

i have a code that isnt running through all the if statements

The problem is how you have used IF and ELSIF. All character codes in the text 'skating' are all non-zero, so if ('skating') ...

17 dagen ago | 0

Answered

Convert a cell array (each cell having different no. of elements) to matrix

Download PADCAT from here: https://www.mathworks.com/matlabcentral/fileexchange/22909-padcat and use it like this: A = padcat...

Convert a cell array (each cell having different no. of elements) to matrix

Download PADCAT from here: https://www.mathworks.com/matlabcentral/fileexchange/22909-padcat and use it like this: A = padcat...

18 dagen ago | 1

| accepted

Answered

Applying whos to each field of a struct

Using a nested function avoids the need for counting input arguments, simplifies the code somewhat, and might make collating the...

Applying whos to each field of a struct

Using a nested function avoids the need for counting input arguments, simplifies the code somewhat, and might make collating the...

19 dagen ago | 0

Answered

how to store every element of a cell array in a separate folders

As soon as you start numbering variable names like n1, n2, n3, ... then you have painted yourself into a corner and made your ta...

how to store every element of a cell array in a separate folders

As soon as you start numbering variable names like n1, n2, n3, ... then you have painted yourself into a corner and made your ta...

19 dagen ago | 1

Answered

need to convert a cell into a vector number

C = {'80,47,109,44,104,40'} % why is this in a scalar cell array? V = sscanf(C{:},'%f,',[1,Inf])

need to convert a cell into a vector number

C = {'80,47,109,44,104,40'} % why is this in a scalar cell array? V = sscanf(C{:},'%f,',[1,Inf])

21 dagen ago | 0

| accepted

Answered

Variables created in different formats

Your file is not really a Comma-Separated Values (CSV) file, it actually uses a tab as the values delimiter and comma as the dec...

Variables created in different formats

Your file is not really a Comma-Separated Values (CSV) file, it actually uses a tab as the values delimiter and comma as the dec...

21 dagen ago | 0

| accepted

Answered

How do I make a section of a function runs only one time?

The MATLAB approach is to move that code outside of the function and parameterize the function call: https://www.mathworks.com/...

How do I make a section of a function runs only one time?

The MATLAB approach is to move that code outside of the function and parameterize the function call: https://www.mathworks.com/...

22 dagen ago | 0

Answered

How to convert all of a structures fields into strings that represent the complete names.

The only general solution is to use a recursive function. Here is code which works for scalar structures, although you could ext...

How to convert all of a structures fields into strings that represent the complete names.

The only general solution is to use a recursive function. Here is code which works for scalar structures, although you could ext...

22 dagen ago | 0

| accepted

Answered

How to get the order if one column has same number and other column has different values

Simpler and more efficient using basic logical indexing: arg = [zeros(7,1);1;1;1] dtm = datetime(2022,2,25,19,[6;6;6;6;7;7;7;8...

How to get the order if one column has same number and other column has different values

Simpler and more efficient using basic logical indexing: arg = [zeros(7,1);1;1;1] dtm = datetime(2022,2,25,19,[6;6;6;6;7;7;7;8...

23 dagen ago | 0

Answered

How can I copy lines of an external text file to another file

tmp = readlines('a.txt'); writelines(tmp(5:end),'new.txt')

How can I copy lines of an external text file to another file

tmp = readlines('a.txt'); writelines(tmp(5:end),'new.txt')

24 dagen ago | 1

Answered

How to Swap alternate rows of a column matrix

Simple approach using indexing (only works for matrices with an even-number of rows): inp = randi(9,8,4) out = inp([2:2:end;1:...

How to Swap alternate rows of a column matrix

Simple approach using indexing (only works for matrices with an even-number of rows): inp = randi(9,8,4) out = inp([2:2:end;1:...

24 dagen ago | 0

Answered

Input as the hexadecimal number

Since R2019b it is possible to directly enter literal hexadecimal and binary numeric values: https://www.mathworks.com/help/mat...

Input as the hexadecimal number

Since R2019b it is possible to directly enter literal hexadecimal and binary numeric values: https://www.mathworks.com/help/mat...

24 dagen ago | 0

Answered

How to count a character string position?

S = '00101100'; X = strfind(S,'1'); fprintf('The places with data are %s\n',join(string(X),", "))

How to count a character string position?

S = '00101100'; X = strfind(S,'1'); fprintf('The places with data are %s\n',join(string(X),", "))

24 dagen ago | 0

| accepted

Answered

fprintf question about column

x=0:0.168:1.68; Y=0:0.015:0.15; nodes=1:1:numel(Y); temp = sqrt(nodes); fprintf('%9s %15s %15s %15s\n','nodes','x-position',...

fprintf question about column

x=0:0.168:1.68; Y=0:0.015:0.15; nodes=1:1:numel(Y); temp = sqrt(nodes); fprintf('%9s %15s %15s %15s\n','nodes','x-position',...

25 dagen ago | 0

Answered

How open a folder without the files beginning with '.'

"What are they..." dot directory names, where '.' represents the directory itself and '..' its immediate parent. .DS_Store is ...

How open a folder without the files beginning with '.'

"What are they..." dot directory names, where '.' represents the directory itself and '..' its immediate parent. .DS_Store is ...

25 dagen ago | 0

| accepted

Answered

Optional graphics handle as first argument in function

From my reading of the "Function Argument Validation" documentation here: https://www.mathworks.com/help/matlab/matlab_prog/fun...

Optional graphics handle as first argument in function

From my reading of the "Function Argument Validation" documentation here: https://www.mathworks.com/help/matlab/matlab_prog/fun...

25 dagen ago | 0

| accepted

Answered

Using Parfor when calling thousands of .mat files

Your code is overly-complex: you need to let DIR to do more of your work for you. P = "D:\Git Repo\FYP\Results\400x400 Chanagin...

Using Parfor when calling thousands of .mat files

Your code is overly-complex: you need to let DIR to do more of your work for you. P = "D:\Git Repo\FYP\Results\400x400 Chanagin...

25 dagen ago | 0

| accepted

Answered

Setfield vs dot indexing for deeply nested struct

"However, Matalb suggests I use dot notation and dynamic fieldnames instead of setfield and getfield whenever possible." Ignore...

Setfield vs dot indexing for deeply nested struct

"However, Matalb suggests I use dot notation and dynamic fieldnames instead of setfield and getfield whenever possible." Ignore...

25 dagen ago | 0

| accepted

Answered

This file format i want to extract time and Value. What should I do??

tbl = readtable('textfile.txt','delimiter','\t') tod = timeofday(tbl.Var1) val = tbl.Var2

This file format i want to extract time and Value. What should I do??

tbl = readtable('textfile.txt','delimiter','\t') tod = timeofday(tbl.Var1) val = tbl.Var2

26 dagen ago | 0

Answered

Read a Special Text File

Here are two much more efficient approaches. The first is exactly like you are doing now, just adding the WHITESPACE option to ...

Read a Special Text File

Here are two much more efficient approaches. The first is exactly like you are doing now, just adding the WHITESPACE option to ...

27 dagen ago | 2

| accepted

Answered

Write cell array, table into text file?

Fake data just for testing the code: dtm = datetime(2021,3,[1;2;31],'Format','dd-MM-yyyy') num = [15;10;2] Connvert data (fro...

Write cell array, table into text file?

Fake data just for testing the code: dtm = datetime(2021,3,[1;2;31],'Format','dd-MM-yyyy') num = [15;10;2] Connvert data (fro...

27 dagen ago | 1

| accepted

Answered

Arrange the array to give the added output in other array

A = [2;1;4;2;8;4;1;7;2]; B = [1;2;3;4;5;6;7;8;9]; [X,Y,Z] = unique(A); N = accumarray(Z,B) display(X)

Arrange the array to give the added output in other array

A = [2;1;4;2;8;4;1;7;2]; B = [1;2;3;4;5;6;7;8;9]; [X,Y,Z] = unique(A); N = accumarray(Z,B) display(X)

28 dagen ago | 0

| accepted

Answered

How to get nan as output if the function output argument is not supported?

if isequal(logical_out,0) run_time = NaN; reaction_time = NaN; return end

How to get nan as output if the function output argument is not supported?

if isequal(logical_out,0) run_time = NaN; reaction_time = NaN; return end

29 dagen ago | 0

| accepted

Answered

textscan error only in loop: "Invalid file identifier. Use fopen to generate a valid file identifier"

This will not work as you require: fname=[pname, fname]; Instead you should use FULLFILE, to correctly handle the file separat...

textscan error only in loop: "Invalid file identifier. Use fopen to generate a valid file identifier"

This will not work as you require: fname=[pname, fname]; Instead you should use FULLFILE, to correctly handle the file separat...

29 dagen ago | 0

| accepted