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

4 years 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',...

4 years 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 ...

4 years 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...

4 years 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...

4 years 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...

4 years 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

4 years 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 ...

4 years 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...

4 years 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)

4 years 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

4 years 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...

4 years 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")

4 years 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 ...

4 years 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....

4 years 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...

4 years 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{:}

4 years 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...

4 years ago | 1

| accepted

Answered
Arrayfun with multiple variable?
"But if I have a function that requires more than one input how can I do?" ARRAYFUN already works with any number of input arra...

4 years ago | 0

Answered
Output cell values and column number for matrix with specific values
Without changing the input matrix A: A = [1,128,1,0,0,0,0,0,0,0,0,0,0;1,129,0,1,1,1,0,1,1,0,0,0,1;1,130,1,0,1,0,0,0,0,1,0,0,0;1...

4 years ago | 0

Answered
How to reshape matrix by column number?
D = [1,78,0,0,0,0,0,0,0,0,8,45,0;1,79,0,0,0,0,31,8,0,0,0,0,0;1,80,456,0,4,0,39,0,0,0,16,0,0] M = D(:,3:end).'; [C,R] = find(M)...

4 years ago | 1

Answered
Comparing Strings and Finding Differencies
Your current approach and other simple code based on STRCMP or comparing entire character vectors is not robust to insertions, d...

4 years ago | 1

Answered
Convert cell array containing hex and scientific notation into hex
Method one: CELLFUN: C = {'4a3';'8.00E+1';'3f00';'503'} X = contains(C,["+","-"]); F = @(s)sprintf('%x',sscanf(s,'%f')); C(X...

4 years ago | 0

| accepted

Answered
Concatenate fields of a structure
Note that using a string array is much more efficient than storing scalar strings in a cell array. app.C1.DHO = {{"ID1","GD1","...

4 years ago | 0

| accepted

Answered
How to read and separate specific parts (letters and numbers) in the same rows of a text file
fnm = 'brdc0250.txt'; opt = detectImportOptions(fnm,'FileType','fixedwidth', 'ExpectedNumVariables',11, 'VariableNamingRule','p...

4 years ago | 1

| accepted

Answered
how to save workspace variables with the same name they have in work space
A much simpler approach ist use SAVE's regular expression syntax: save('mydata.mat', '-regexp','^PSD') See the examples here: ...

4 years ago | 1

Answered
I want to include a variable in my figure title when I save to a directory.
TIMEend = 2029; fnm = sprintf('Final E monoton %u.fig',TIMEend); fpt = fullfile('.','PRCC plots for submission 2',fnm); savea...

4 years ago | 0

| accepted

Answered
How to programmatically modify substructure with arbitrary number of levels?
I would not write a function for this, just use SETFIELD with a comma-separated list: S.a.b = 1; C = {'a','b'}; N = 2; S = s...

4 years ago | 0

| accepted

Answered
Finding when spline interpolated data is equal to a number
X = [1,2,3]; Y = [1,2,4]; Yq = 3; pp = spline(X,Y); fh = @(xq)ppval(pp,xq)-Yq; Xq = fzero(fh,[1,4]) plot(X,Y,'+',Xq,Yq,'*'...

4 years ago | 0

| accepted

Answered
How to re-order a string array?
P = pwd; S = dir(fullfile(P,'*.txt')); C = {S.name}; [~,X] = sort(str2double(regexp(C,'\d+','match','once'))); C = C(X);

4 years ago | 0

| accepted

Load more