Answered
How to go through multiple subfolders for operation?
"For better explaining if i have one folder named 'JSR' which contains subfolders name '1', '2', '3', '4'...................

8 years ago | 0

| accepted

Answered
hi, im tring to make a new vector from some exics one.
The MATLAB way: >> grades = [87,81,87,80,94,87,62]; >> sch = grades(grades>85) sch = 87 87 94 87

8 years ago | 0

Answered
Please Assist with plotting graph from multiple files, so far the code only reads one file a multiple times.
D = 'C:\Users\NSebopetse\Pictures\nakampe-optiplex-760'; S = dir(fullfile(D,'san_2018*')); % better to include the file extensi...

8 years ago | 0

| accepted

Answered
How to group dynamically different fields from a structure ?
This is a very good example of why putting meta-data into variable names or fieldnames makes code pointlessly complex. If that d...

8 years ago | 1

| accepted

Answered
i have more than 100 mat files with data inside them. how to extract all the data inside the matlab file to the matlab workspace so that i can plot a graph with it ? Help me..
https://www.mathworks.com/help/matlab/import_export/process-a-sequence-of-files.html Simply load each mat file into a variable,...

8 years ago | 0

| accepted

Answered
How to select a folder using uigetdir and use folder location later?
Do NOT use strcat, you should always use fullfile to build filepaths, just like you did for dir. Like this: aa = fullfile(direc...

8 years ago | 1

| accepted

Answered
how can an function containing structure data can be used in main code while main code also containing same/different structure.
function c = practice2; str2.d = randi([0,10],1,8); c = str2.d; end and then: str1.a=randi([0,10],1,8); str1.b=randi([-1...

8 years ago | 0

| accepted

Answered
Unexpected fault in input
You did not enter any value, so FF is empty. Any empty array cannot be expanded to fill the non-empty locations that you have s...

8 years ago | 1

Answered
What is wrong with the indexing
MATLAB does not allow parentheses to trail other parentheses, so this is now allowed: diff(y,t)(0) You will have to use a temp...

8 years ago | 0

Answered
how to remove some lines of a file?
I suspect that you want something like this: beg = '*Elset, elset=granulation'; % first line to remove. num = 4; % lines to re...

8 years ago | 0

Answered
How to randomize a specific number of 0s and 1s so that 0s always precede at least two 1s?
>> n0 = 70; >> n1 = 170; >> v = char('0'+[zeros(1,n0),ones(1,n1-2*n0)]); >> v = strrep(v(randperm(numel(v))),'0','110')-'0'; ...

8 years ago | 1

Answered
Regexp formatting and explanation
>> S = '0051-21194_3 Rev 09_P02109461-011_8-1-18'; >> R = '^(\d+-\d+)[^R]{0,4}(Rev\s\d+)\w+-\d+_(\d+-\d+-\d+)$'; >> T = regexp...

8 years ago | 1

Answered
How to parse variables independent of order
It would help most if you uploaded a sample file, so we have something to work with. But here is a simple working example of how...

8 years ago | 2

| accepted

Answered
find the longest monotonically increasing subsequence of a sequence of n numbers?
A simple recursive function does the trick: function V = longestMono(S) %S = [18,32,5,6,17,1,19,22,13]; V = []; for k = 1:nu...

8 years ago | 1

| accepted

Answered
How to plot a simple function that has a variable?
You can do this very simply by defining a normal function handle: >> F = @(x,a) x.^2 + a*x - 6; >> X = -10:.1:10; >> plot(X,F...

8 years ago | 0

Answered
replace all values of cells between two positions
For an aribtrary number of rows and an aribitrary number of indices using loops is about the most straightforward way of doing t...

8 years ago | 2

| accepted

Answered
I have a 16x31x17 double matrix which various different values. I want to find out the location of one single value which is 305.3. How can i do that ?
Where A is your 16x31x17 array: X = abs(A-305.3)<1e-5; [R,C,P] = ind2sub(size(X),find(X))

8 years ago | 0

Answered
How to clear existing array size? I am getting "Subscripted assignment dimension mismatch" Error.
clear is rarely needed in well written code. It is usually simpler and more efficient to just let MATLAB manage the memory by co...

8 years ago | 0

Answered
How to convert a string (eg ABCD12134) i.e a combination of text and numbers to a double ?
>> s = 'ABCD12134'; >> sscanf(s,'%*[^0123456789]%f') ans = 12134 >> sscanf(s,'%*[A-Z]%f') ans = 12134 >> str2double(regex...

8 years ago | 0

Answered
how to count the number of different elements in two matrices
Simpler: mean(a~=b)

8 years ago | 1

Answered
How to cell array of string to 3D matrix?
This converts your supplied cell array (attached) into a numeric array: >> C = cellfun(@(s)sscanf(s,'%f'),AB,'uni',0); >> A = ...

8 years ago | 0

| accepted

Answered
Find empty cells in excel
You used the wrong kind of indexing. You need to use curly braces: isempty(raw{6,1}) ^ ^ The differ...

8 years ago | 0

Answered
create indexes of x in a for loop
It is not very clear what you are trying to achieve, but it is possible to store a function handle in a cell array: C = cell(1...

8 years ago | 0

Answered
Concatenate rows within a 3D cell array
Try something like this: baz = @(c) horzcat(c{:}); foo = @(x) cellfun(baz, num2cell([x.A;x.C;x.E],1), 'uni',0); arrayfun(foo,...

8 years ago | 0

| accepted

Answered
Unable to save variables and figures of large arrays
"what is the meaning of this error?" The .fig file format is really just a .mat that stores all of the objects in a figure. Mos...

8 years ago | 0

| accepted

Answered
How to load a .mat file and make all the variables from that .mat file to be global variables?
Always load any .mat file into an output argument (which is a structure): S = load(...); This avoids several issues related to...

8 years ago | 1

| accepted

Answered
How to loop through cell arrays
S = size(H); for rx = 1:S(1) for cx = 1:S(2) H{rx,cx} end end

8 years ago | 0

Answered
Is there a function/command call that does 2-d logical
Either you can get a vector of only the values that you want (like you were getting), or you can have a matrix by replacing the...

8 years ago | 1

Answered
My 'for' loops aren't altering anything except a few points in my matrices
Problem: it is very simple: you are using a syntax that does not do what you think it does. This syntax n_B > i > 1 is actu...

8 years ago | 0

| accepted

Load more