Answered
VERY odd error with simple multiplication ... OK... not so odd.
"Does anyone have any idea why this is happening?" Yes, the behaviors of floating point numbers are quite well documented, and ...

8 years ago | 3

| accepted

Answered
Creating a variable from part of a string
I recommend that you use a structure instead of magically accessing variable names: >> x = 'dr_1e-2_A1_OFF_A2_OFF.txt'; ...

8 years ago | 1

| accepted

Answered
How to count the top five pairs (for each digit) which have the highest number of occurrences in a cell array?
Simpler: >> C = {[1;3;5;4;6]; [1;2;3;4;5;6;7]; [1;4;3;6]}; >> H = cellfun(@(v)hankel(v(1:end-1),v(end-1:end)),C,'uni',0)...

8 years ago | 1

Answered
How can I extract L, A and B value from LAB value ?
L = lab_he(:,:,1); a = lab_he(:,:,2); b = lab_he(:,:,3); To save: csvwrite('L.csv',L) etc.

8 years ago | 0

| accepted

Answered
cell to matrix with numerical and logical values
Where each cell contains a scalar numeric or logical: cell2mat(cellfun(@double,C))

8 years ago | 0

Answered
How to count the total number of occurrences of each digit in cell arrays?
>> C = {[1; 4; 7]; [2; 5; 8; 9]; [3; 4]}; >> V = cellfun(@(v)v(2),C); >> U = unique(V); >> N = histc(V,U); >> [U,N...

8 years ago | 0

| accepted

Answered
How to interpolate based on given column
No need to use interpolation, just some simple, efficient arithmetic: >> V = [0.2;0.8;1.0;1.3;0.8;2.3;4.9;10.0;0.2;5;2.3;8....

8 years ago | 1

| accepted

Answered
Speed up for loop, accumarray
This gives exactly the same output as your code: H = accumarray(reshape(idx,[],3),1); First I ran your code on some rand...

8 years ago | 1

| accepted

Answered
How to create large data in MATLAB. For large array showing out of memory.
<https://www.mathworks.com/help/matlab/large-files-and-big-data.html> <https://www.mathworks.com/help/matlab/import_export/ta...

8 years ago | 0

Answered
is it possible to input two variable values while loading a function from commend menu?
You should use |sprintf| and |fullfile|: D = 'directory where the folders should be located'; for ii = 1:n B = sp...

8 years ago | 0

Answered
Function returns wrong data if fed a list of numbers instead of a single number
The simple MATLAB solution is to use logical indexing: x = 0:0.1:200; y = x; y(x>75) = 25; plot(x,y) If you wan...

8 years ago | 2

Answered
Compare column vector to column in a Matrix and extract data
Do not use loops for this. MATLAB is a high-level langauge, it is not C++. It is not completely clear what you expect to get,...

8 years ago | 2

Answered
How do I use the strsplit function to split a sentence into a string of letters?
It is not very clear what exactly you want to achieve (you did not give any input and output examples), but here are some possib...

8 years ago | 0

Answered
How TABLE retreive the variable names?
<https://www.mathworks.com/help/matlab/ref/inputname.html>

8 years ago | 1

| accepted

Answered
too many input arguments
The first input to |prctile| must be numeric (double or single). So your cell array will need to be converted to numeric. You wr...

8 years ago | 0

| accepted

Answered
ODE, how to retrive variables computed in the previous step
The simplest solution is: use <https://www.mathworks.com/help/matlab/matlab_prog/nested-functions.html nested functions>. Wri...

8 years ago | 1

| accepted

Answered
add blank spaces in cell array
>> ar = [0,1,0,0,0,0,0,0,0,0;0,0,0,3,0,0,0,0,0,0;0,0,0,0,0,0,2,0,0,0;0,0,0,0,0,0,0,0,3,0;4,0,0,0,0,0,0,0,0,0] ar = 0 ...

8 years ago | 0

Answered
how do i discretize negative integers
_"This works for positive integers only"_ Actually |histc| works perfectly for negative values. It works for me: >> x = ...

8 years ago | 1

| accepted

Answered
Strange problem with sin.
_"Strange problem with sin."_ So what _is_ the problem? You did not tell us what you _expect_ to get for the output values, o...

8 years ago | 0

| accepted

Answered
In a sorted vector ,how do I compare first element to other elements and then find if there are any duplicates , if yes take their indexes and replace it with 0
For a sorted row vector. Find duplicates of the first element, as you requested: >> A = [1,1,2,3,4]; >> X = A(1)==A; ...

8 years ago | 1

| accepted

Answered
How to rename an array inside an .mat file?
_"I have 8 separate files with an array in each. I am trying to import them but they all have the same array name. How do I chan...

8 years ago | 0

Answered
Help with an error occurring
The only mention of |displayWaveformLabels| I can find is on this page: <https://www.mathworks.com/help/signal/examples/wavef...

8 years ago | 1

| accepted

Answered
Managing several GUIs through a script
_"I'm pretty sure I can do it with global variables but I'm trying to avoid using them"_ Avoiding global variables is a good ...

8 years ago | 1

| accepted

Answered
How can I index these matrix blocks into numbers?
Actually you can already access it like you want, using linear indexing. Try it: C{1} C{2} ... C{16} Here is a ...

8 years ago | 0

| accepted

Answered
Extract part of string using REGEXP
Use a look-around operation to ensure that the previous character was alphanumeric: >> C = {'R44821_181026120003i3t001B02f0...

8 years ago | 0

| accepted

Answered
How to plot for a matrix?
You for to use the index |k| from the outer loop: % Fitzhugh-Nagoma model parameters e = 0.01; k = 1:1:4; a = 0.1;...

8 years ago | 0

| accepted

Answered
Converting the Cell array Contents to Matrix
Where |C| is your cell array: [C{:}] or horzcat(C{:}) Depending on the required order you might need to transpos...

8 years ago | 0

| accepted

Answered
Need help concatenating data with struct field name?
Create a cell array from the structure field: names = {s.name} This syntax uses a comma-separated list: <https://www....

8 years ago | 0

| accepted

Answered
How do i get my graph to produce a straight line other than just points? Thanks.
The basic problem is that you are plotting individual points inside a loop. This approach will never get you a joined-togethe...

8 years ago | 0

Answered
Create a vector by selection randomly vectors
Having separate vectors is a pain to work with, so the first thing to do is to put them into one matrix |M|: >> M = [1,2,3,...

8 years ago | 2

Load more