Answered
how to save figure with command
You do not say anything about the file format that you want to use, however these will likely cover you needs: doc print ...

8 years ago | 1

Answered
How can I use the function blkdiag without typing every single matrix?
"Do we have a simple and fast way to do this operation without typing every single one?" Of course, this is simple, just use a ...

8 years ago | 3

| accepted

Answered
could you please tell me how to extract data from any matfile for a particular latitude and longitude?
By using indexing: lat = 23; % the latitude you want. vec = 0:100; idx = lat==vec; out = mat(:,idx,:,:)

8 years ago | 1

| accepted

Answered
How to find the second closest value to a specific value from a given matrix
Exactly as I showed you in <https://www.mathworks.com/matlabcentral/answers/426517-how-to-find-the-value-closest-to-1-from-a-x-y...

8 years ago | 0

| accepted

Answered
Shifting row and column of a matrix with minimum and maximum to the top and right repectively?
A simple MATLAB way (no loops, just basic indexing): >> M = randi(9,7,5) M = 5 1 4 1 9 7 8 2 6...

8 years ago | 1

Answered
Help my imputdata not solve
Importing that file (attached) is made more complicated by the fact that is uses a _decimal comma_, whereas MATLAB only parses a...

8 years ago | 1

| accepted

Answered
Delete Lines if there are three e qual lines
This should get you started: >> A = [1,3,7,8,9,7,2,8;9,0,3,5,2,1,4,9;0,2,3,6,2,7,7,7;3,2,3,5,2,2,5,7] A = 1 3 ...

8 years ago | 1

Answered
How can i change the precision using datenum?
The basic problem is that |intersect| tests for exact equivalency of floating point numbers (which is all that |datenum|'s are)....

8 years ago | 0

| accepted

Answered
How do I find absolute max value in a vector without losing the sign when the value is negative in MatLab R2011b?
*Method one:* use indexing to select from the original vector: >> V = [2,6,-7]; >> [~,X] = max(abs(V)); >> V(X) an...

8 years ago | 3

| accepted

Answered
fplot gives me an error "function behaves unexpectedly on array inputs".
_"Doese anyone know how to fix this?"_ The <https://www.mathworks.com/help/matlab/ref/fplot.html |fplot|> documentation descr...

8 years ago | 0

Answered
How to find the value closest to 1 from a x*y*z double matrix ?
>> [~,x] = min(abs(k(:)-1)); >> [p,n,m] = ind2sub(size(k),x) p = 6 n = 9 m = 2 >> k(p,n,m) ans = 0.99869...

8 years ago | 0

| accepted

Answered
Perform a program that shows the series 1!/2!, 2!/3!, 3!/4!, .....
A loop is not required, simple vectorized code will do this: >> V = factorial(1:11); >> V(1:10)./V(2:11) ans = ...

8 years ago | 0

Answered
How do you create a string from two strings by intersecting them char by char to form a new word using a loop?
Loop not required, just use indexing: *Method one:* >> str1 = 'Hello'; >> str2 = 'Canada'; >> strN = [str1,str2]; ...

8 years ago | 1

| accepted

Answered
problem of generations of values in a matrix
>> V = [4,3,2]; % [#1s, #2s, #3s, etc.] >> F = @(v,n)n*ones(1,v); >> C = arrayfun(F,V,1:numel(V),'uni',0); % or use REPE...

8 years ago | 1

Answered
how i change the data from column to rows. it try on transpose but give wrong result.
C = cellstr(P).' ^^ you need to transpose if you want a row cell vector.

8 years ago | 1

| accepted

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

Load more