Answered
Unable to load multiple mat files
theFiles is already a structure, there is no point in creating another one when you can use theFiles already: myFolder = 'C:\Us...

4 years ago | 0

Answered
Error using second . Invalid date/time class. (I am working on guide)
Subtracting a DATETIME object from a DATETIME object, as you do on that line, returns a DURATION object. However the function S...

4 years ago | 1

Answered
Subscripted assignment between dissimilar structures within a table
A 1x1 structure is not empty, it is scalar: its size is independent of how many fields it has. You are trying to assign a struc...

4 years ago | 0

| accepted

Answered
What is the way to get only the desired part of the text?
txt = fileread('test.txt'); tkn = regexp(txt,'^(\w+):\s+(\d*\.?\d*)(\S*)','tokens','lineanchors'); tkn = vertcat(tkn{:}) vec ...

4 years ago | 0

Discussion


TUTORIAL: Comma-Separated Lists and How to Use Them
Introduction Comma-separated lists are really very simple. You use them all the time. Here is one: a,b,c,d That is a comma-se...

4 years ago | 11

Question


TUTORIAL: Comma-Separated Lists and How to Use Them
Introduction Comma-separated lists are really very simple. You use them all the time. Here is one: a,b,c,d That is a comma-se...

4 years ago | 2 answers | 7

2

answers

Answered
How do I use fprintf and looping to create a table from a single randomized variable?
Well, you made a reasonable start with this homework. I left small part for you to do: x = [-1.4074954934790074e+02,+1.15596735...

4 years ago | 0

| accepted

Answered
function is not working
old_num = '17'; old_base = 8; new_base = 7; result = base2base(old_num, old_base, new_base); fprintf('%i\n', result) %% !!!...

4 years ago | 0

Answered
When plotting datetime seconds are displayed as miliseconds
"How can this be corrected." Use the correct format (possibly when importing the data, we do not know how you defined those dat...

4 years ago | 0

| accepted

Answered
Graph Not Plotting for the For Loop Code
"What am I missing? " Assigning the values to an output array via indexing. Because you did not use indexing to assign the val...

4 years ago | 0

| accepted

Answered
Look up a value in an incomplete list
Simpler and more efficient: keys = ["a","b","c","d"]; vals = [3,4,2,1]; x = ["c","d","e"]; [idx,idy] = ismember(x,keys); ou...

4 years ago | 0

| accepted

Answered
How to generate Data using for loop
The simple and efficient MATLAB approach would be to use REPELEM, for example: val = [200,500,800,1000,800,900]; num = [120,40...

4 years ago | 0

| accepted

Answered
What are some good examples of non-continuous colormap applications?
"Are they particularly well suited to coloring 3D shapes/contours (as the name "colorcube" seems to imply)?" No, not particular...

4 years ago | 2

Answered
How to assign specific values to pixels?
m = [1,22,33;44,55,66;77,188,255] % pixel default value v = [1,1;22,4;33,9;44,35;55,48;66,90;77,99;188,200;255,300] % txt file ...

4 years ago | 0

| accepted

Answered
Finding the start of a number in one array based on the values of another.
x = [0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0]; y = [1,1,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1]; ...

4 years ago | 0

| accepted

Answered
Set value to an array element if the index exceeds the number of array elements
V = 1:5; k = 6; try N = V(k) catch V(k) = 0; end display(V)

4 years ago | 0

| accepted

Answered
Why can't I run my code
Move the function to the end of the script. The function(s) must come after all other code: https://www.mathworks.com/help/matl...

4 years ago | 0

Answered
How to convert a 4D double matrix into a cell array
A = rand(376,30,20,44); C = num2cell(A,1:3); C = reshape(C,1,[])

4 years ago | 0

| accepted

Answered
how to make an anonymous function with more than 1 statement or equation?
Using anonymous functions: B=2; C=4; Fa = @(x) B.*x; Fd = @(x) C.*x.^2; Fh = @(x) sqrt(Fa(x)+Fd(x)); Fh(2) Using the symb...

4 years ago | 0

| accepted

Answered
How to fprintf a transposed matrix?
fprintf(..,T.'); % ^^ Or skip T entirely: fprintf(..,A); In MATLAB, just like in many other mathematical computati...

4 years ago | 2

Answered
Run multiple scripts in random order
To run scripts you can use RUN: C = {'arrangement1.m', 'arragement2.m', 'arrangement3.m'}; for k = randperm(numel(C)) run...

4 years ago | 1

| accepted

Answered
How to check equality of very small numbers ?
A = 1.309998142150646e-09; B = 1.309998162564509e-09; Method one: compare the absolute difference against a tolerance: tol = ...

4 years ago | 0

| accepted

Answered
How to get Unique values from two columns at a time?
You could use UNIQUETOL, for example: M = [0.075278,0.213,18,127;0.075278,0.220,16,127;0.075278,0.248,31,129;0.075278,0.307,22,...

4 years ago | 0

| accepted

Answered
MD5 hash of .mat files varies
"Is this because of compression when the .mat file is saved?" No, it is beacuse the .mat file includes the date and time when i...

4 years ago | 1

| accepted

Answered
Set multiple fields of a struct to a certain value?
"Set multiple fields of a struct to a certain value?" What your example shows is how to set one field of multiple elements of a...

4 years ago | 0

| accepted

Answered
Error on loop on multiple ASCII files
You should specify the path when importing the file data, for example: P = 'F:\Teamdrive\TEST'; S = dir(fullfile(P,'**','*.asc...

4 years ago | 0

| accepted

Answered
How to sequentially read .txt file to .mat with random names available in a folder
Sorting the filenames into alphanumeric order is not required for your task. The code below: Does not require the subject numb...

4 years ago | 0

Answered
Combining a number and a string array (both columns) into a single column string array.
The simple MATLAB approach: V = linspace(1,10,10); S = "X=" + V(:)

4 years ago | 1

Answered
Using 'Char' Information As A Variable Name
That would be complex and very inefficient. Your suggested approach is best avoided. A much simpler approach is to store the im...

4 years ago | 0

Answered
Use string name as variable name for struct
D.A__B__C = 0.5; D.A__B__D = pi F = fieldnames(D); C = regexp(F,'_+','split'); Z = struct(); for k = 1:numel(F) Z = se...

4 years ago | 0

| accepted

Load more