Answered
Horizontally concatinating the fields of a structure with different dimensions.
The different number of rows does not prevent them from being concatenated vertically: >> S.f1 = [0,1;2,3;4,5]; >> S.f2 = [6,7...

7 years ago | 0

| accepted

Answered
How to change string name?
The solution is to simply use indexing. For example, you could put all of your imported data into one cell array. You did not gi...

7 years ago | 2

| accepted

Answered
How to extract locations from strings of addresses?
Using one simple regular expression: >> C = {... 'Sustainable Industrial Systems, School of Chemical Engineering and Analyti...

7 years ago | 1

| accepted

Answered
I need some help with understanding the '2' close to the second d
>> fprintf ('The square of %d is %2d\n', [a;asq]) The square of 1 is 1 The square of 2 is 4 The square of 3 is 9 The squa...

7 years ago | 0

Answered
How to get a value from a matrix?
You should never compare for exact equivalence of floating point numbers, read this to know why: https://www.mathworks.com/matl...

7 years ago | 0

| accepted

Answered
Convert character matrix to numeric matrix
If you really need a 2x2 array then one straightforward way would be to use a cell array: >> A = {'AB','AC';'AD','AE'} A = ...

7 years ago | 1

| accepted

Answered
how can i split matrix into two part?
p1 = PP(1:v,:); p2 = PP(v+1:end,:); Note that I got rid of the superfluous square brackets.

7 years ago | 1

| accepted

Answered
How to create a loop function for a set of parameters from a file to define each parameters as variables
Dynamically creating variable names is not recommended. Read this to know why: https://www.mathworks.com/matlabcentral/answers/...

7 years ago | 0

Answered
Converting Cell Array into Array
for i=1:4 % Some calculations here rSet = ... C{i,1} = rSet; end vertcat(C{:})

7 years ago | 1

Answered
Too many input arguments.
MATLAB's ftrans2 has either one or two inputs. The documentation does not mention or show three input arguments.

7 years ago | 0

| accepted

Answered
fprintf for 6 array in double type and 2 date vectors
Your format string does not match your data. In your question you describe and show 2 char variables and 6 numeric variables, bu...

7 years ago | 0

| accepted

Answered
How to fill matrix in for loop?
>> (0.7:0.05:1).'*(0:0.2:1) ans = 0.00000 0.14000 0.28000 0.42000 0.56000 0.70000 0.00000 0.15000 0.30000...

7 years ago | 1

| accepted

Answered
Vectorizing for loop with with strcmp function inside
Reverse the loop order and get rid of the cell2mat: for ii = numel(A):-1:1 idx = strcmp(A(:,2),A(ii,1)) & strcmp(A(:,1),A(...

7 years ago | 0

Answered
How can I concatenate a large number of matrices?
C = arrayfun(fun,1:N,'uni',0); M = vertcat(C{:}) Read about how this works: https://www.mathworks.com/help/matlab/matlab_prog...

7 years ago | 0

| accepted

Answered
How to save inner loop data with outer loop data in one matfile
Using a structure (or any other array) is better than using dynamically named variables: m = 2; n = 3; r = 5; V = 2:2:20; f...

7 years ago | 1

| accepted

Answered
Turning numbers from string into doubles / into table with doubles
>> S = '[21, 22, 34,36]'; >> V = sscanf(S(2:end),'%f,') V = 21 22 34 36

7 years ago | 0

| accepted

Answered
How can I make a column appending columns which are of size of sum of other column?
>> lat = [1,2,3,4,5]; >> CG = [5,10,20,11,12]; >> V = cell2mat(arrayfun(@(v,n)v*ones(n,1),lat(:),CG(:),'uni',0)) V = 1 ...

7 years ago | 0

| accepted

Answered
Reshape the Matrix to complex number ?
Some methods to get the original (complex) matrix back: Method one: reshape and matrix multiplication: Y = reshape(Xd,[],2)*[1...

7 years ago | 0

| accepted

Answered
regex not working to replace numbers with enclosing brackets numbers
>> regexprep('t1 w1 r2 (L2) d1 L12aa','([twLr])(\d+)','$1($2)') ans = 't(1) w(1) r(2) (L(2)) d1 L(12)aa' You might also like t...

7 years ago | 0

Answered
Create a character cell in ascending order
N = 1000; C = cell(1,N); for k = 1:N C{k} = sprintf('variable%d',k); end

7 years ago | 0

Answered
How to skip some values in for loop ?
Just add this line after those loops: I_dd(B==0) = 0 to get this: I_dd(:,:,1) = 1 4 5 6 0 0 7 0...

7 years ago | 1

| accepted

Answered
Problem introducing user input into an array
Simpler: bny = input('Insira o codigo a codificar: ' ,'s'); idx = ismember(bny,'01'); assert(all(idx),'Input must contain onl...

7 years ago | 0

| accepted

Answered
Taking the kronecker product of multiple matricies, nested in an array
A = [1,1;0,1]; B = [1,0;1,0]; C = {A,B,B,A,A,B}; S = C{1}; for k = 2:numel(C) S = kron(S,C{k}); end

7 years ago | 0

| accepted

Answered
Table: Overwrite column value with condition
This might work: myTable.a(myTable.a < 3) = 0;

7 years ago | 1

| accepted

Answered
Understanding indexing and the colon operator
The end keyword simply refers to the last column (it can also be used for rows, etc.): https://www.mathworks.com/help/matlab/re...

7 years ago | 1

| accepted

Answered
Concatenating data from structure array for plotting
Nested structures do not allow that syntax, so the simplest solution is to use temporary variables to unnest those structures (t...

7 years ago | 0

| accepted

Answered
Read numbers and characters from text file into a single array
opt = {'CollectOutput',true}; fmt = '%f%f%*s%f%*s%f%f%f'; [fid,msg] = fopen('test.txt','rt'); assert(fid>=3,msg) C = textsca...

7 years ago | 0

Answered
convert cell array to structure with first row as field names
Use cell2struct, possibly something like this (where C is your cell array): S = cell2struct(C(2:end,:),C(1,:),1)

7 years ago | 0

| accepted

Answered
How can I access my command history without running Matlab program?
The command history is stored in either: history.xml (R2014a or later) history.m (earlier versions) https://www.mathworks.com...

7 years ago | 1

Load more