Answered
why fopen can't generate a valid file identifier (when create new file with permission of 'writing')
[fid,msg] = fopen(outfilename,'w'); assert(fid>=3,msg) fprintf(fid,'sub_num\tsub_ini\tage\tgender\n'); fclose(fid); ...

8 years ago | 0

| accepted

Answered
Randomization of columns of 3 cell arrays and accessing data
|eval| is, like always, a red-herring that just distracts and misleads from finding real solutions. Beginners do this because th...

8 years ago | 1

| accepted

Answered
String and two variables
sprintf('T_DCT_PK_WDT_W%02dB%d_RANGE',i,a) For example: >> sprintf('T_DCT_PK_WDT_W%02dB%d_RANGE',5,1) ans = T_DCT_P...

8 years ago | 0

Answered
plotting N number of lines without for-loops
Simpler: >> N = 5; >> S = randi(9,N,3); >> E = randi(9,N,3); >> A = permute(cat(3,S,E),[3,1,2]); >> plot3(A(:,:...

8 years ago | 0

Answered
Reference a cell array using a string to specify image data for imwrite
Simply put all of your cell arrays into *one* structure (or another cell array), and then you can trivially use indexing to acce...

8 years ago | 1

| accepted

Answered
How to create matrix from descending number of vector elements without loop?
>> V = [1 2 5 3 4]; >> flipud(tril(repmat(V,5,1))) ans = 1 2 5 3 4 1 2 5 3 0 1 2 5...

8 years ago | 2

Answered
Is it possible to automatically pass a predefined value to a variable assigned to questdlg, inputdlg, uigetdir (without the input window pop up)?
Ugh, this is an unfortunate situation to find oneself in... my commiserations. One possible solution is to shadow those function...

8 years ago | 1

| accepted

Answered
ismember on cell array and remplace values
c1={'ESP00021','ESP00023','ESP00023'}; % a row vector! c2={'ESP00023','ESP00025'}; % a row vector! [~,idx] = ...

8 years ago | 0

| accepted

Answered
How do I create an axes on a figure?
Your units and position are incongruous. If you use |'normalized'| then _all_ of the position values will (almost always) be bet...

8 years ago | 0

| accepted

Answered
How to extract a number from a string array?
_"How can extract the first three digit value only so that I get a matrix that is 164 165 165"_ With a simple application of ...

8 years ago | 1

| accepted

Answered
How to choose a random value from an array?
>> X = A(3,:)<50; % columns with <50 in third row >> V = find(X); >> C = V(randi(nnz(X))) % random column C = 3 >...

8 years ago | 0

| accepted

Answered
How to make a matrix with all possible combination?
[A,B] = ndgrid(-2:2); [A(:),B(:)] For a general solution, try this: n = 3; C = cell(1,n); [C{:}] = ndgrid(-n:n); M = resha...

8 years ago | 1

| accepted

Answered
count occurrences of sub-string in a long string (How many times a sub-string appear)
>> str = '3A9059D46237,2047DAACE894,2047DAACE894,2047DAACE894,2047DAACE894'; >> C = regexp(str,'\w+','match'); >> [uni,~...

8 years ago | 1

| accepted

Answered
Strange Cell Array error
c2 = str2double(data(:,h+1))

8 years ago | 0

| accepted

Answered
Is it possible to call a vector(row/column) into a matrix instead of using for loop ?
If the function |fun| has been written to accept a 1x1xN vector, then of course your could do this: fun(reshape(x,1,1,[])) ...

8 years ago | 0

| accepted

Answered
How can i update the type of axis in my GUI ?
Within the button callback set the axes' |XScale| property: <https://www.mathworks.com/help/matlab/ref/matlab.graphics.axis.a...

8 years ago | 0

| accepted

Answered
why am i getting this error ? what to do?
*Read the error message*. Is |datadir = 'C:\Users\AKASH\Pictures\works\**'| a directory that exists on your computer? Is |C:\Use...

8 years ago | 0

Answered
Please Help me about matlab code
The problem is how you are calling the function. |quantilereg| is a function that requires three input arguments: quantiler...

8 years ago | 0

Answered
creating a list of strings with different numbers and same letters
This is easy using sprintf: D = 'MyFolder'; for kk = 0:100 fnm = fullfile(D,sprint('f%dK.csv',kk)); MyFiles(kk+1,:) ...

8 years ago | 0

| accepted

Answered
multiple interp1 without loop
Try using a loop with <https://www.mathworks.com/help/matlab/ref/interp1q.html |interp1q|>.

8 years ago | 0

Answered
Time Stamp is a Large Number
Use either <https://www.mathworks.com/help/matlab/ref/readtable.html |readtable|> or <https://www.mathworks.com/help/matlab/ref/...

8 years ago | 0

| accepted

Answered
How to extract only floating numbers from a string
>> S = '21.5VgDC_0.05000V_VgAC_50M-150M30ms47GV1'; >> C = regexp(S,'\d+\.?\d*','match'); >> C{:} ans = 21.5 ans = ...

8 years ago | 2

| accepted

Answered
How to number permutation values in "for" loop to be sequentially printed as 1, 2, 3 etc?
cnt = 0; for ii = 1:3 for jj = 1:3 for kk = 1:3 cnt = cnt+1 ... ...

8 years ago | 1

| accepted

Answered
How to use two colormaps (of different size) in same figure with one axes?
I think the easiest solution would be to use two axes, and stack the quiver axes on top of the map axes (both of these are done ...

8 years ago | 1

Answered
Concatenate vectors in cell array { } or matrix [ ] with coordinates
A(2:3,2) = {4;5} And for a numeric/char/logical/...: M(2:3,2) = [4;5]

8 years ago | 0

| accepted

Answered
min/max indexing of array
Using a logical comparison is much simpler: >> E(bsxfun(@ne,E,min(E,[],3))) = NaN E = ans(:,:,1) = NaN ...

8 years ago | 0

| accepted

Answered
Having Trouble With Preallocating
m = zeros(1000000,2); Although a better idea would be to preallocate with the exact required size: L = numel(x); m...

8 years ago | 0

| accepted

Answered
How To Make Code Run Faster
1. The most important change you could make would be to preallocate the matrix |m|: <https://www.mathworks.com/help/matlab/ma...

8 years ago | 0

| accepted

Answered
How to replace nan with the mean of the four numbers surrounding it?
Download this FEX submission: <https://www.mathworks.com/matlabcentral/fileexchange/4551-inpaint-nans>

8 years ago | 0

Answered
How to publish MATLAB plots as graphs (including data points), and not just snapshots of the plot ?
Change the image format: <https://www.mathworks.com/help/matlab/matlab_prog/specifying-output-preferences-for-publishing.html...

8 years ago | 0

Load more