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') ...

14 jours 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...

15 jours 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...

16 jours 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...

16 jours 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])

18 jours 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...

18 jours 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/...

19 jours 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...

19 jours 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...

20 jours 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')

21 jours 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:...

21 jours 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...

21 jours 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),", "))

22 jours 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',...

22 jours 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 ...

22 jours 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...

22 jours 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...

22 jours 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...

23 jours 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

23 jours 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 ...

24 jours 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...

24 jours 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)

25 jours 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

26 jours 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...

26 jours ago | 0

| accepted

Answered

Conversion of string containing "AM" or "PM" to datetime

str = "4/21/2022 8:48:40 AM"; dtm = datetime(str, "InputFormat", "M/d/u h:m:s a")

Conversion of string containing "AM" or "PM" to datetime

str = "4/21/2022 8:48:40 AM"; dtm = datetime(str, "InputFormat", "M/d/u h:m:s a")

26 jours ago | 1

| accepted

Answered

I am getting the error "Variable y must be of data type char. It is currently of type double."

extractemail('My email address is: raymond.kim@usc.edu so please email me') extractemail('There is no email here') function ...

I am getting the error "Variable y must be of data type char. It is currently of type double."

extractemail('My email address is: raymond.kim@usc.edu so please email me') extractemail('There is no email here') function ...

26 jours ago | 0

Answered

Store values from a matrix in a new size matrix

Assuming that you intend to print the matrix into a file (as your example shows): inp = randi(9,340,340); fmt = [repmat(' %15....

Store values from a matrix in a new size matrix

Assuming that you intend to print the matrix into a file (as your example shows): inp = randi(9,340,340); fmt = [repmat(' %15....

27 jours ago | 0

| accepted

Answered

Function Named with String Substitution

"Is there a way in MatLab to use string substitution in the name creation of each function? " Yes, but only if you want to forc...

Function Named with String Substitution

"Is there a way in MatLab to use string substitution in the name creation of each function? " Yes, but only if you want to forc...

28 jours ago | 0

| accepted

Answered

Split an Array in sub-arrays based on the first number in the column

M = [[0;0.2;0.2;0.4;0.6;0.6;0.6],rand(7,3)] D = diff(find([1;diff(M(:,1));1])); C = mat2cell(M,D,4) C{:}

Split an Array in sub-arrays based on the first number in the column

M = [[0;0.2;0.2;0.4;0.6;0.6;0.6],rand(7,3)] D = diff(find([1;diff(M(:,1));1])); C = mat2cell(M,D,4) C{:}

28 jours ago | 1

| accepted

Answered

Indexing inside variables name

for k = 1:N v1 = sprintf('Data%u_Asc',k); v2 = sprintf('Data%u_BML',k); fn = sprintf('File%u.mat',k); save(f...

Indexing inside variables name

for k = 1:N v1 = sprintf('Data%u_Asc',k); v2 = sprintf('Data%u_BML',k); fn = sprintf('File%u.mat',k); save(f...

28 jours ago | 1

| accepted