Answered
how to rename files .tif in a folder ?
D = 'C:\Users\ASUS\Desktop\2'; S = dir(fullfile(D,'*.tif')); for k = 1:numel(S) [~,F] = fileparts(S(k).name); if ~is...

8 years ago | 0

| accepted

Answered
How do I make EXTRAPVAL a scalar?
Add str2double: a = str2double(input(prompt,'s')); ... b = str2double(input(prompt,'s')); This is more robust than calling i...

8 years ago | 0

Answered
Call a Matrix inside another Script
Actually all you need in your script is this: psm_q = [pi/3; pi/3; 0.1; pi/3; pi/3; pi/3];

8 years ago | 0

Answered
How to add scalar to empty matrix?
Where val is possibly empty, and the ouput should be a scalar: tmp = [val,0]; tmp(1) If the output could be non-scalar, then ...

8 years ago | 0

| accepted

Answered
How to transpose a cell array converted into a character arrray?
Converting to a horizontal character array is easy with a comma-separated list: >> C = {'Green','Blue','Red'}; % orientation is...

8 years ago | 0

Answered
series of consecutive numbers in a matrix
This is MATLAB, so get rid of the pointless loops: >> M = [2 3 5; 6 1 3; 4 5 6; 3 3 3; 9 8 7; 1 2 3] M = 2 3 5 6 ...

8 years ago | 0

Answered
Add a number every n values
>> B = reshape(A,3,[]); >> B(4,:) = 800; >> B = reshape(B,1,[]) B = 1 2 3 800 4 5 3 800 0 ...

8 years ago | 0

Answered
how can i find the numbers and their indices which are same
M = [1,3,4,36;3,2,2,5;5,5,6,8;3,4,1,23;3,12,6,34;1,5,3,1;11,17,12,9;17,19,26,26;16,1,1,27;18,10,18,15]; for k = 1:size(M,1) ...

8 years ago | 1

| accepted

Answered
How to fix error done by pressing 'Cancel' button using App Designer?
Try reading the uigetdir help, where it explains that "If the user clicks Cancel or the close button (X) on the title bar, then ...

8 years ago | 1

| accepted

Answered
Error using sortrows, too many input arguments
sortrows(srt,[-1,-2]) But your allocation does not make much sense: srti(j,3)=sortrows(srt,...) because you try to force two...

8 years ago | 1

| accepted

Answered
Put matrix in cell
Simpler: >> T = [3,6,1,12,7,10,6,0,0,22,0,15;2,4,4,3,2,4,5,0,0,20,0,4;0,1,0,2,0,2,0,0,0,17,0,16;0,5,0,6,0,7,0,0,0,6,0,0;0,0,0,0...

8 years ago | 0

| accepted

Answered
Can someone please help me answer this question, I have no idea what to do.
Consider what the difference between values actually is, and try some examples: >> diff([2,5]) ans = 3 >> diff([2,5,9]) ...

8 years ago | 1

| accepted

Answered
random vector (1,10)
ceil(a*rand(1,10)) Often beginners think of using round for something like this, but the usual algorithm they use has nasty end...

8 years ago | 1

Answered
Can someone help me with this question? I keep getting the error "Not enough input arguments. Error in assesment2question1 (line 5) for m = 1:N"
The simple solution using an anonymous function: >> func = @(x,N) sum(bsxfun(@power,x,(1:N).'),1); >> X = -0.5:0.1:0.5; >> pl...

8 years ago | 0

Answered
How can i allocate results in matrix with for loop?
This is MATLAB, so just get rid of the pointless loops entirely: >> w = 0:4; >> t = 0:9; >> y = exp(t.*w(:).*1i) y = Col...

8 years ago | 0

| accepted

Answered
assigning value to a changing struct field
ytpe = {'P','G'}; % more robust as cell array. axis = {'x','y','z'}; % more robust as cell array. for ii = 1:numel(ytpe) ...

8 years ago | 0

Answered
Basic operations with matrices
Assuming that each .mat file contains only one variable and there are no other similarly named .mat files in the same directory:...

8 years ago | 1

| accepted

Answered
how to reverse the process of matrix conversion to structure?
This is MATLAB, so loops are not required: rows = 480; cols = 800; MAT = randi(9,rows,cols); % fake data matrix Rb = 16; % ...

8 years ago | 2

| accepted

Answered
how to match and eliminate those values??
"i am not able to understand this" Your code: find(codes~=s)) first creates a logical array with the same size as codes, with...

8 years ago | 1

| accepted

Answered
How to import an equation that is user defined in GUI into separate m files?
Use str2func to generate a nice function handle that you can use/pass to your other code. Note that you will need to prefix the...

8 years ago | 1

Answered
syntax to used unmatched values in matlab?
Method one: setdiff: >> s = [1,1,0,0,0,0,1,1,0,0,1,1,1,1,0,0] s = 1 1 0 0 0 0 1 1 0 0 1 1 1 1 ...

8 years ago | 0

Answered
How can I increase the precision of the y axis?
yticks(-5:5)

8 years ago | 0

| accepted

Answered
Why does function isscalar() return "1" for function handles?
Because the documentation states that "A function handle is always scalar (1-by-1)." https://www.mathworks.com/help/matlab/matl...

8 years ago | 2

| accepted

Answered
Interp1 on a cell array
>> A = {[],[],4,5,6,7,[],[],8,[],5,[],[]}; >> idx = find(~cellfun('isempty',A)); >> idy = idx(1):idx(end); >> new = interp1(i...

8 years ago | 1

| accepted

Answered
why is there a smiley face when use imagesc
That is not a smiley face, it is a photo of Steve Eddins' eldest son: https://blogs.mathworks.com/steve/2006/10/17/the-story-be...

8 years ago | 1

| accepted

Answered
How do I compare the result of the output of a loop with the previous output of the loop?
Put your entire if... ifelse ... end inside another if: if i>1 if size(...) ... elseif size(...) .....

8 years ago | 0

| accepted

Answered
How do I store matrices into a cell array in the correct order?
"When I store the cell array, for some reason the elements are stored in reverse order." Not at all. They are stored in the exa...

8 years ago | 0

| accepted

Answered
How can I count the word "the" in a paragraph (a ".txt" file) creating an array?
This actually works: >> C = regexp('the cat in the hat','\s+','split'); >> nnz(strcmpi(C,'the')) ans = 2

8 years ago | 0

Answered
Concatenation is missing values
33 of the cells in the third column contain empty arrays: >> find(cellfun('isempty',cellStruct(:,3))) ans = 21968 2196...

8 years ago | 2

| accepted

Load more