Answered
Understanding the difference between ndgrid and meshgrid (from Numpy)
If you must replicate numpy.meshgrid (with the default indexing='xy') then do not use ndgrid, unless you want to waste time perm...

5 years ago | 1

| accepted

Answered
Find only numeric strings on cellstr array.
Writing regular expressions or pattern matching that robustly detects all valid number formats is not such a trivial task... it ...

5 years ago | 1

Answered
convert an array of 0s and 1s to binary & reverse
B = [0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1]; D = pow2(7:-1:0)*reshape(B,8,[])

5 years ago | 1

Answered
How I can detection column indexes of string 'rn_mill_tonnage' (n=1,2,3,4....)
C = {'X','Y','Z','size(X)','size(Y)','size(Z)','volume','r1_cu_mill_grade','r1_mill_tonnage','r2_cu_mill_grade','r2_mill_tonnage...

5 years ago | 0

| accepted

Answered
I am unable to understand the use of ~ here.I know that find peaks returns two arguments x and y axis of peak
https://www.mathworks.com/help/matlab/matlab_prog/ignore-function-outputs.html In both of the examples you show, the code's aut...

5 years ago | 0

Answered
error in my code
You need to download this FEX submission (by clicking on the big blue "Download button"): https://www.mathworks.com/matlabcentr...

5 years ago | 0

Answered
from C_T_Sep_1 to C_T_Sep_10 they are vectors the same thing for C_A_Sep_1... C_A_Sep_10, I want to create matrix C_T_Sep and C_A_Sep and put the vector inside it, using loop
Your code design makes your task much harder. By forcing meta-data into the variable names, you have forced yourself into writin...

5 years ago | 0

| accepted

Answered
get 0 in the end of a regexp function
x = 1.2569e-15; v = regexprep(sprintf('%#.6g',x),{'\.','e.+'},'')-'0'

5 years ago | 0

Answered
extract numbers from cells
Simply download my FEX submission SIP2NUM: https://www.mathworks.com/matlabcentral/fileexchange/53886-scientific-prefix-to-numb...

5 years ago | 0

Answered
how to form a two-column array for a given but dimmension-unknown array?
"I am wondering if there is a simple way to form array C without checking the dimmensions of A and B." C = [A(:),B(:)]

5 years ago | 0

| accepted

Answered
How to extract some values from a structure?
Assuming that structure A is scalar (so far you did not tell us this important information): A.x = randi(9,1,100); A.y = randi...

5 years ago | 0

| accepted

Answered
Extract data from a cell contains of alphabet and number
"I have read the contents from file and I have a cell which contians 10133x1 cell array. The cell array contains of letter and n...

5 years ago | 0

| accepted

Answered
Accessing multiple columns in cell array
Fake data: Data = arrayfun(@(n)randi(9,2,3),1:5,'uni',0).'; % fake data Data{:} Method one: M = mean(cat(3,Data{:}),3); M =...

5 years ago | 0

Answered
Import multiple .txt files by dates from user input
"What would be the best way to approach this?" Your approach of manipulating dates as strings is inefficient because it require...

5 years ago | 0

| accepted

Answered
Concatenate variables with similar names
"Using a loop." Then that is where you should fix the bad code design. Meta-data is data, so store it in arrays, not in variab...

5 years ago | 0

| accepted

Answered
"Access Elements of a Nonscalar Structure Array" issue
sys = fakedata() fnm = regexp(fieldnames(sys),'^system\d+$','match'); fnm = [fnm{:}] fun = @(f)sys.(f).subsystem.mass; out =...

5 years ago | 0

Answered
Error using conv2 N-D arrays are not supported.
Perhaps you could use convn instead of conv2: I = imread('peppers.png'); lpf1 = 1./[16,8,16;8,4,8;16,8,16]; lpf2 = 1./[10,10,...

5 years ago | 1

| accepted

Answered
How can I concatenate vectors based on a grouping label contained by a separate variable?
N = ["charlie_test_a";"charlie_test_b";"charlie_test_c";"jane_test_a";"jane_test_b";"mildred_test_a";"mildred_test_b";"mildred_t...

5 years ago | 0

| accepted

Answered
For loop to create a new matrix taking a cluster of columns from existing matrix
The MATLAB approach using reshape, permute, and sum: inp = randi([1,20],1300,36) out = sum(permute(reshape(inp,1300,4,[]),[1,3...

5 years ago | 1

Answered
How to skip lines after the header line when using readtable
type test.csv opts = detectImportOptions('test.csv'); opts.DataLines = 3; opts.VariableNamesLine = 1; T = readtable('test.cs...

5 years ago | 6

| accepted

Answered
Add names to table variables from a large cell
% Fake data: V = {[1,3,4],[4,7,8],[1,2]}; A = randi(9,5,4); % Create table: F = @(n)sprintf("{%s}",join(string(n),",")); T ...

5 years ago | 0

| accepted

Answered
Why readtable() function cannot read an xlsx file properly?
This is caused by the different row lengths in sheet 3: the shortest row has just 7 non-blank cells, the longest row has 147 non...

5 years ago | 1

| accepted

Answered
how to separate string matrix by zeros
This would have been easier if you had imported the data as numeric, rather than as string. Rather than relying on low-level lo...

5 years ago | 0

| accepted

Answered
Create table from structure - alignment
Simpler: mom.a = 1; mom.b = 2; mom.veryLongName = 3; hdr = {'Moment'; 'Value'}; tmp = [fieldnames(mom),struct2cell(mom)].';...

5 years ago | 0

| accepted

Answered
Rearranging array based on number of steps.
https://www.mathworks.com/help/matlab/ref/reshape.html https://www.mathworks.com/help/matlab/ref/permute.html A = 1:24; N = 3...

5 years ago | 1

| accepted

Answered
How to select a specific element in a table using variables corresponding to table headers
How to select data from a table is explained here: https://www.mathworks.com/help/matlab/matlab_prog/access-data-in-a-table.htm...

5 years ago | 0

| accepted

Answered
json char with too many decimals, need removal
str = '{"hund": 0.3253533250000000000000000000000000, "kat": "dfsdfs", "baenkebider": 0.002021203321320000000000000000000000}'; ...

5 years ago | 0

| accepted

Answered
How to replace cell values with consecutive values related to their index
Simpler: C = {cell(1,1),cell(1,5),cell(1,3)} N = cellfun(@numel,C); D = mat2cell(1:sum(N),1,N)

5 years ago | 1

Answered
How can I remove . and ..
Replace {sad([sad.isdir]).name} with setdiff({sad([sad.isdir]).name},{'..','.'})

5 years ago | 0

| accepted

Load more