Answered
Measure the time spent by a function
Use the profiler: <https://www.mathworks.com/help/matlab/ref/profile.html> <https://www.mathworks.com/help/matlab/matlab_p...

9 years ago | 0

Answered
How can I extract specific rows from one array to another array?
The problem is that you test for equivalence of floating point values. This is bound to cause errors, as has been discussed hund...

9 years ago | 1

| accepted

Answered
Code to zoom in 2D plot?
Simply set the X and Y limits of the <https://www.mathworks.com/help/matlab/ref/matlab.graphics.axis.axes-properties.html axes p...

9 years ago | 1

| accepted

Answered
Use terminal to speed up file removal
Remove the |textread| and replace it with something like this (pseudocode): fid = fopen(...,'rt'); fgetl(fid); % read fi...

9 years ago | 0

Answered
My matlab code is giving me this error "Too many outputs requested". If someone can help me solve this?
There is nothing preventing you from having zero, one, or more values returned. You need to take into account those situations. ...

9 years ago | 0

Answered
Change visibility of a frame with a push button
You should use <https://www.mathworks.com/help/matlab/ref/strcmpi.html |strcmpi|> to compare, not <https://www.mathworks.com/hel...

9 years ago | 1

| accepted

Answered
remove elements from a matrix
Very simply using <https://www.mathworks.com/help/matlab/ref/cumprod.html |cumprod|>: >> M = [1,1,1,1,1,1,0,0,0,0,0,0;1,1,1...

9 years ago | 0

| accepted

Answered
How to compare matrix elements with their neighbors?
There is no need to write loops. Simply generate an index by identifying the locations that meet your conditions: >> M = ra...

9 years ago | 2

Answered
How can I plot several graphs with slightly different name in a loop?
How MATLAB works is different to what you are attempting: you simply allocate values into the array using indexing, rather than ...

9 years ago | 0

Answered
Longest segment of successive numbers of a sequence
>> V = [1,2,7,8,3,9,4,7,2,5,7,8,9]; >> D = [0,find([diff(V)<0,true])]; >> [~,X] = max(diff(D)); >> V(D(X)+1:D(X+1)) ...

9 years ago | 0

| accepted

Answered
Wanted: Examples on how to use "Dynamic Regular Expressions" to debug regular expressions
As far as I can tell there is no simple "regexp-debug" tool or method, but here are a few tips based on my experience writing my...

9 years ago | 2

| accepted

Answered
I want to build a structure that includes multiple matrices
A cell array would be simpler than a structure: >> C = num2cell(zeros(100,3),2); >> C{1} ans = 0 0 0 >> ...

9 years ago | 0

Answered
cannot iterate over subdirectories from data structure
You need use <https://www.mathworks.com/help/matlab/matlab_prog/access-data-in-a-cell-array.html cell array indexing> with a cel...

9 years ago | 1

| accepted

Answered
How do I create a loop that goes up by 5 until a certain number and then up by 3?
A simpler concept using |for|: s1 = 5; s2 = 3; V = 12:s1:31+s1; for k = [V,V(end)+s2:s2:50] ... end

9 years ago | 0

Answered
How can I find number of words from a text file which ends with 'ed', 'es' and 'ing'?
It would be much simpler to use <https://www.mathworks.com/help/matlab/ref/regexp.html |regexp|>: >> str = fileread('sample...

9 years ago | 0

| accepted

Answered
How to reshape two matrices row wise with out changing the order
reshape([A,B]',1,[])

9 years ago | 1

| accepted

Answered
Putting a matrix into an array
Into a 3D array: T = nan(4,4,N); T(:,:,1) = makehgtform('translate', [1,1,0]); T(:,:,2) = makehgtform('translate', [1...

9 years ago | 0

| accepted

Answered
Code to compare cells with a range in MATLAB
There is no point in writing MATLAB code like complex C++ code, with lots of loops and ifs. MATLAB code should be elegant, clear...

9 years ago | 1

Answered
Recurring Sequences of Numbers
>> fun = @(N)round(cos((1:N)*pi/2)); >> fun(10) ans = 0 -1 0 1 0 -1 0 1 0 -1 >> fun(4) ans = ...

9 years ago | 0

| accepted

Answered
How to cross-reference values in one array with another (of different sizes)
ismember(Array1,Array2)

9 years ago | 0

| accepted

Answered
How to separate element in row with different length?
Two lines, no loop: >> a = {9611013;12811019;3211001;6411007;9611013;12811019;16011025;3211001;6411007;9611013;12811019;160...

9 years ago | 1

Answered
Assignment help for MATLAB? Overall confusion and unable to interpret instructions fully, as well as code problems.
Take a deep breath, you are doing just fine! _"I don't know what's wrong and even I did, I doubt I'd know how to fix it."_ ...

9 years ago | 0

| accepted

Answered
How to plot row vectors in a matrix in which every marker is a different color and repeated amongst the other rows?
Because the markers and lines are perpendicular to each other (wrt. the input variables) it is not possible to define them both ...

9 years ago | 3

| accepted

Answered
Different variables depending on which file is loaded
Put the filename in a variable, and use |switch|: fnm = 'SIXRX2.txt'; S = load(fnm); ... switch fnm case 'S...

9 years ago | 0

| accepted

Answered
if else statement problems
The problem is very simple: your code only loops over one value: for i = 10 Whereas you probably wanted to loop over te...

9 years ago | 1

| accepted

Answered
Calling Functions from file names
S = dir(fullfile(myFolder,'models','*.m')); for k = 1:numel(S) [~,N] = fileparts(S(k).name); fun = str2func(N...

9 years ago | 0

| accepted

Answered
Create a 3D matrix from multiple 1D vectors without FOR loop
St = zeros(3,3,L); St(1,1,:) = Sxxi; St(1,2,:) = Txyi; St(1,3,:) = Txzi; St(2,1,:) = Txyi; St(2,2,:) = Syyi; ...

9 years ago | 1

Answered
how to calculate the value?
You really need to learn the difference between matrix operations and array operations: <https://www.mathworks.com/help/matla...

9 years ago | 1

| accepted

Answered
How do I find a file name containing a particular string in a given directory and read this present file and write into other folder.
*Method one: |strfind|:* P = 'E:\folder'; S = dir(fullfile(P,'*.jpg')); N = {S.name}; X = ~cellfun('isempty',strfi...

9 years ago | 0

Load more