Answered
how i will make function or code for creating pair of 3 element form this string={A, R ,N ,D,C,E,Q,G,H,I,L,K,M,F,P,S,T,W,Y,V}.
>> V = 'ARNDCEQGHILKMFPSTWYV'; >> [X,Y,Z] = ndgrid(1:numel(V)); >> P = V([X(:),Y(:),Z(:)]); >> size(P) ans = ...

8 years ago | 1

| accepted

Answered
how can convert string to matrix?
Get rid of the nested loops, they are not an effective use of MATLAB. It is much simpler and more efficient to use basic inde...

8 years ago | 0

Answered
a function with increasing number of its arguments in a loop
Use a comma-separated list: N = ... number of iterations C = cell(1,N); % output array for k = 1:N T = repmat(...

8 years ago | 0

Answered
How can i do apply operator componentwice in any vector in N dimensional space? Mat lab code for any vector in N dimension
Simpler: >> v = [-20;9;-50;90;60;8;16;50;-43] v = -20 9 -50 90 60 8 16 5...

8 years ago | 1

Answered
use 2D matrix as index to sum certain levels in the 3rd dimension of a 3D matrix
A = randi(99,300,300,50); % data X = randi(50,300,300); % indices B = sum(A.*double(reshape(1:50,1,1,[])<=X),3); ...

8 years ago | 3

| accepted

Answered
How can I save indices of a circle without losing the circle shape?
The problem is on the very last line: z(row,col)=1; If you must use |find| then you will either have to use |sub2ind| to...

8 years ago | 1

| accepted

Answered
bsxfun when inputs are scalar and vector
|bsxfun| is totally the wrong tool to use. You just need to <https://www.mathworks.com/help/matlab/matlab_prog/vectorization.htm...

8 years ago | 0

| accepted

Answered
how to replace 'x\d+' by 'X(...same number as \d+ ...)' such as x45 --> X(45) using regexprep ?
>> str = ' h(1) = -(x21 + x53)/x9 + x183 '; >> regexprep(str,'x(\d+)','X($1)') ans = h(1) = -(X(21) + X(53))/X(9) + X(1...

8 years ago | 0

| accepted

Answered
which plotting function can give me this curve
>> x = 0:0.1:2*pi; >> v = (0:3).'; >> A = sin(x)+v-0.1; >> B = sin(x)+v+0.1; >> plot(x,A,'--') >> set(gca,'Next...

8 years ago | 1

Answered
Extracting from a matrix
Where |A| is your matrix: B = A(2,1:600) Basic MATLAB concepts, like how to use indexing, are explained in the introduct...

8 years ago | 0

| accepted

Answered
convert the values of a vector into a matrix and move the vector positions.
>> a = [3,9,32,6,5,6,7,1,2,10]; >> toeplitz(a(5:end),a(5:-1:1)) ans = 5 6 32 9 3 6 5 6 ...

8 years ago | 2

| accepted

Answered
append array of 1xn in mat file and as a result it should be look like kxn. k=3
You will have to do one of these: # on each iteration <https://www.mathworks.com/help/matlab/ref/load.html |load|> the data, ...

8 years ago | 1

| accepted

Answered
exstract consecutive duplicate element of array
>> A = [1,2,3;1,2,7;3,4,9;9,9,9;7,7,7] A = 1 2 3 1 2 7 3 4 9 9 9 9 7 7 7 ...

8 years ago | 1

Answered
how to load a text file and convert it to hexadecimal and vice versa ?
>> str = '1Hello'; >> hex = dec2hex(double(str)) hex = 31 48 65 6C 6C 6F >> char(hex2dec(hex)).' ...

8 years ago | 0

| accepted

Answered
Extract 2D matrix from 3D matrix with different lengths.
For just one matrix use either A = reshape(B(:,1,:),17,[]); or A = permute(B(:,1,:),[1,3,2]); For all of the mat...

8 years ago | 1

| accepted

Answered
How to use cell2mat for specific elements of cell array?
C = cell2mat(B(:,1:3)); C = C(:,2:3); _"What am I missing here?"_ Several things: firstly, that the |B{...}| syntax c...

8 years ago | 0

| accepted

Answered
How to find a minimum in this matrix ?
I have no idea how this will compare to using a few loops: A = randi(999,8,7,6,5,4,3); % fake data in 8x7x6x5x4x3 array. ...

8 years ago | 1

| accepted

Answered
Merging contents of multiple MAT files
To read the files in the correct order download my FEX submission natsortfiles: https://www.mathworks.com/matlabcentral/fileexc...

8 years ago | 0

| accepted

Answered
format data into string and write a txt file
A cell array of numeric vectors is quite inconvenient to work with, so the first thing to do is convert it to a much easier to u...

8 years ago | 0

| accepted

Answered
How to use a variable only defined in a function in your script?
Your usage of the function |angle| has several bugs, in particular: # You do not call |angle| with any output arguments, alth...

8 years ago | 0

Answered
how to find common values in two matrix for particular column?
You don't need to use a loop: >> sum(permute(A,[3,2,1])&permute(B,[2,3,1]),3) ans = 1 0 1 2 0 1 2 ...

8 years ago | 1

Answered
extracting numbers with different decimal extention
>> S = 'OutputY: 35,40 50 57,80 57 54,71 58,73 61,01 61,67 60,02 57,57 57,51 61,11 64,55 ...

8 years ago | 0

| accepted

Answered
Assigning small matrices in a large matrix in parfor loops
R = 20; N = 3; C = cell(1,N); parfor ii = 1:N A = zeros(3,3); for jj = 1:3 if jj == 1 ...

8 years ago | 0

| accepted

Answered
Replace for loop with matrix function, for function acting on matrix columns
Using <https://www.mathworks.com/help/matlab/matlab_prog/compatible-array-sizes-for-basic-operations.html implicit scalar dimens...

8 years ago | 2

| accepted

Answered
How to get selected folders from multiple folders in a directory?
To randomly select four folder names: D = 'path of the directory where the folders are'; S = dir(fullfile(D,'*')); X ...

8 years ago | 1

| accepted

Answered
Loading a variable from deferent .mat files selected using GUI matlab
>> new.X1_BA_time = 1:3; >> new.X1_DE_time = 4:6; >> new.X1_FE_time = 7:9; >> C = fieldnames(new); >> X = cellfun(...

8 years ago | 1

| accepted

Answered
create a vector with 10 to power negative number
All you need is this: 10.^(0:-1:-16)

8 years ago | 1

| accepted

Answered
sub2ind Get values of 3D matrix using an index vector
Given: A = 37x30x100000 matrix C = 37x1 vector of column indices *Method one: |ndgrid|:* S = size(A); [Rx,~,P...

8 years ago | 0

Answered
Alternatives for using EVAL to access data in multi-layered struct?
One simple solution is to use <https://www.mathworks.com/help/matlab/ref/getfield.html |getfield|> and <https://www.mathworks.co...

8 years ago | 2

| accepted

Answered
even after using fopen, still giving negative fid. how to get a valid fid?
You need to actually pass the filename to |fopen|: fnm = fullfile(matlabroot,'1.txt'); [fid,msg] = fopen(fnm,'r'); as...

8 years ago | 0

Load more