Answered
Multi-dimentional arrays with matlab
"i have read that one cannnot work with multi dimentional arrays in matlab" Instead of reading incorrect and/or misleading stat...

8 years ago | 1

Answered
How to delete all the contents in a folder using matlab
Use rmdir(root_dest,'s') % ^^^ you need this to also delete all of the folder contents. This is explained in th...

8 years ago | 2

| accepted

Answered
Converting a base ten number into a base two number?
x = 47.1875; % Integer part: n = 1+fix(log2(x)); I = nan(1,n); y = fix(x); for k = n:-1:1 I(k) = fix(mod(y,2)); ...

8 years ago | 0

Answered
Why does hex2num('F') equal -3.1050e+231?
Try hex2dec instead: >> hex2dec('F') ans = 15 "What function gets the expected result of F = 15?" You can easily find these ...

8 years ago | 0

| accepted

Answered
display a struct as table
First convert all of the row vectors to column vectors, and make sure that they all have the same number of elements (the last...

8 years ago | 0

| accepted

Answered
Splitting a long string into individual variables
"... so I'm looking for a way to split them all into their own variables" That would not be a good approach. Read this to know ...

8 years ago | 0

| accepted

Answered
how i can delete useless data from matrix
Do NOT use a loop for this. MATLAB code should be neat and simple: [~,idx] = unique(data(:,[6,8]),'stable','rows'); out = dat...

8 years ago | 0

Answered
How do I implement sort_nat.m a function for opening and reading files?
You can download my FEX submission NATSORTFILES here: https://www.mathworks.com/matlabcentral/fileexchange/47434-natural-order-...

8 years ago | 0

| accepted

Answered
Can I Split the char with out deliminater ? (Please have a look at example)
>> str = 'FD86FA78F79B0425FAEE0866031E02F60742F9840240F6C0F999FE4BF6F407FDFE2208330680FEB20680F6'; >> sscanf(str,'%4x') ans = ...

8 years ago | 0

| accepted

Answered
Pass values to outside of loop after each iteration
Based on your comment "output mat with n no. of row would look like = [w, the vector elements , sum]", perhaps using a cell arra...

8 years ago | 0

Answered
Setting array elements to zero, the best way
Use array(:) = 0; at the start of the loop. This will not require new arrays to be created, which is likely faster... but the ...

8 years ago | 0

| accepted

Answered
fclose - what is the purpose?
Short Answer: Files need to be opened and closed for reasons that depend on how OS's work, not because of how MATLAB works. Fil...

8 years ago | 2

| accepted

Answered
How can i generate this array with matlab?
In two simple steps: >> V = 4:10:194 % 1st step V = 4 14 24 34 44 54 64 74 84 94 104 114 ...

8 years ago | 1

| accepted

Answered
the number of files between two elements of a cell
An effiicent method based on simple logical comparisons of numeric vectors (serial date numbers): >> d1 = '20190102'; >> d2 = ...

8 years ago | 1

| accepted

Answered
How to add inputdlg to my code for taking input ?
Read the inputdlg documentation: it clearly states that the output is "a cell array of character vectors containing one input pe...

8 years ago | 0

| accepted

Answered
Error using movefile: Arguments must contain a character vector.
Read the movefile help: does it say that its first input should be some image data? (hint: no). Does it say that its first input...

8 years ago | 1

| accepted

Answered
How to create a diagonal matrix from several different size matrices
It is not clear if you want those matrices to be converted to a diagonal-only matrix, or if you want a block-diagonal matrix. He...

8 years ago | 0

Answered
My function is returning ans instead of storing my sequence in a variable
"my only problem is it returns ans instead of storing the array in the variable sequence like i thought i told it do do." Just ...

8 years ago | 0

Answered
Matlab hex2dec function not converting hex into dec accurately.
Download John D'Errico's excellent base2base: >> base2base('C3B829A1E8642B78',16,10) ans = 14103068008476060536 Note that you...

8 years ago | 0

| accepted

Answered
Display the ID of the participant who has the fastest response time in Experiment 1
>> [val,idx] = min(T.Experiment1); >> T.ParticipantID(idx) ans = 507

8 years ago | 0

| accepted

Answered
Using FIND for common elements WITHOUT a loop (Vectorized?)
Use ismember and its second output argument: >> A = randperm(5) A = 3 5 4 1 2 >> B = randi(5,1,9) B = 5 1 ...

8 years ago | 0

| accepted

Answered
how to solve Unexpected MATLAB expression in the below line ?
map = [255,255,255;0,0,0;255,0,0;205,133,63;101,67,33;0,134,139]; if any(ismember(color,map,'rows'))

8 years ago | 0

| accepted

Answered
Double for loop to generate vector from sequential results
You are overthinking things, you only need one loop: vs = 1.01:0.01:1.99; s = size(vs,2); ev1 = nan(1,s); % preallocate f...

8 years ago | 0

| accepted

Answered
If I have a cell array how do I convert it into a single char
https://www.mathworks.com/help/matlab/ref/join.html

8 years ago | 1

| accepted

Answered
How to protect my functions which will be called by other programmers?
Two steps: write your function so that at the start it checks something that only you know about: e.g. your username in the abs...

8 years ago | 1

Answered
Specifying the iteration range for 'for' loops
There is no need to use a loop: >> M = randi(9,5,5) % random 5x5 matrix M = 7 1 5 6 6 7 4 8 2 5 7 ...

8 years ago | 2

| accepted

Answered
How to extract 1st digit of each number in an array
Simpler efficient numeric operations, without multiple type conversions: >> x = [12,34,56,999,430,2] x = 12 34 56 ...

8 years ago | 3

Answered
Struct variable save in parfor loop
I doubt that parfor wil work happily with dynamic fieldnames, because their order of definition is ambiguous (e.g .consider nami...

8 years ago | 0

| accepted

Answered
Finding the set of unique values for another set of unique values
>> F = @(v){unique(v,'stable').'}; >> C = accumarray(M(:,1),M(:,2),[],F); >> C{:} ans = 3 4 ans = 5 4 ans = ...

8 years ago | 1

Answered
What is the function of flag in this code?
On each loop iteration the flag value changes sign, so it follows this pattern: +1 -1 +1 -1 ... This has the effect of alt...

8 years ago | 1

| accepted

Load more