Answered
Error : Undefined variable
You incorrectly transcribed the error message: the actual character shown is lower-case L, i.e. l, not a 1 like you showed. To a...

6 years ago | 0

| accepted

Answered
Suppressing ans in a function
To avoid the ans you must use a semi-colon when you call the function: str = encrypt(...); % ^ you need this s...

6 years ago | 0

| accepted

Answered
I keep getting two answers for my code
fconvg = int(k*j, x, 0, t) % ^ missing semi-colon This line should probably come after the if-end. Th...

6 years ago | 0

| accepted

Answered
Solving linear system 2 equations, 2 unknowns, not A = b*C form
Using a numeric solver or the symbolic toolbox is like using a sledge-hammer to crack open a tiny walnut! It is very simple to ...

6 years ago | 1

Answered
Button Colors and Shapes in GUIDE
http://undocumentedmatlab.com/articles/modifying-matlab-look-and-feel https://www.mathworks.com/matlabcentral/fileexchange/4086...

6 years ago | 0

| accepted

Answered
How to find the index of first and last nonzero elements in each column?
This works for any array, 2D, 3D, etc., and returns the requested linear indices: >> A = [0,0,0,0;0,0,0,0;1,0,4,8;2,0,5,9;3,1,6...

6 years ago | 1

Answered
Create one file from many files
D = 'absolute/relative path to where the files are saved'; N = 25; % number of files C = cell(1,N); for k = 1:N F = full...

6 years ago | 0

Answered
Randomly convert exact number of 1 to 0 in binary matrix
>> M = [0,1,0;1,0,1;1,1,1] M = 0 1 0 1 0 1 1 1 1 >> X = find(M); >> M(X(randperm(nu...

6 years ago | 1

Answered
need solution asap for my hw about summing each character in student number that we input the data
The MATLAB way: >> str = input('enter your student number here: ','s'); enter your student number here: 20758562 >> num = sum...

6 years ago | 0

Answered
error Undefined operator '.*' for input arguments of type 'table'.
The problem is very simple: you are using the wrong type of indexing: instead of () you should be using {} to access the content...

6 years ago | 1

| accepted

Answered
Char to Double convertion
>> str = 'LVLG -287.41E-03 -28.401E-03 -2.4001E-03'; >> tmp = regexp(str,'\S+','match'); >> vec = str2double(tmp(2:end)) vec ...

6 years ago | 2

| accepted

Answered
Vertical alignment of input using fprintf
>> x = {'Butane','Oxygen','Nitrogen gas','Maleic anhydride','Acetic acid','Acrylic acid','Carbon monoxide','Carbon dioxide','Wat...

6 years ago | 1

Answered
Evaluate the output of a function returning functions at a given value
Storing the output of a function in a variable is explained in the Introductory Tutorials: https://www.mathworks.com/help/matla...

6 years ago | 0

Answered
Comparing the performance of colon, loop, and cell indexing
"Am I missing something?" 1- accessing data in non-contiguous locations is slow. Consider your indexing output(k,:): because MA...

6 years ago | 0

| accepted

Answered
How can I use a variable number of structure fields as function arguments?
Use struct2cell and a comma-separated list: >> X = fieldnames(MyStruct); >> Y = struct2cell(MyStruct); >> C = [X(2:end),Y(2:e...

6 years ago | 2

| accepted

Answered
finding same pattern files from two different folders and copying to other folders
Read the folder contents using dir. Extract the timestamps (e.g. regexp or indexing) Call intersect on the timestamps, returni...

6 years ago | 0

| accepted

Answered
How to pull value of table for char array?
"When I use the code" t(1,'Domain') then your indexing returns a table, because parentheses is used to return a table (i.e. u...

6 years ago | 2

| accepted

Answered
Executing same function in different elements of an array
Try something like this: B = [2500,5000,...]; % begin indices E = [2800,5300,...]; % end indices N = numel(B); C = cell(1,N)...

6 years ago | 0

| accepted

Answered
Matrix product: inv or \ ?
"Why using \ is faster than inv? Is there a numerical reasone?" Yes: because the two division operators use completely differen...

6 years ago | 0

| accepted

Answered
The min and max function return incorrect result!
The default display format short displays arrays with five significant figure precision and a common multiplier for all values i...

6 years ago | 1

| accepted

Answered
For loop problem; could you help?
thi = 0.1:0.1:1; T = 273.15:1:273.15+60; %%% temperature N = numel(T); w = nan(numel(thi),N); % preallocate! Pg = nan(1,N); ...

6 years ago | 0

| accepted

Answered
Create Matrix By Several Matrices These Matrices Have Elements By Equations
Having lots of numbered variables is not a good approach, you should place all of those sub-matrices into one cell array when th...

6 years ago | 0

Answered
Too many input arguments. (the equations and conditions are given i am running the code but giving error kindly suggest me )
The anonymous function F only has one input argument: F = @(as)... but you are calling it with two inputs: f = F(asc,L); Pro...

6 years ago | 0

Answered
How to perform mathematical operation in columns on certain elements and make the other elements zero??
Something fancy... >> M = [0,0;0,0;1,0;2,7;5,8;3,11;4,12;2,9] M = 0 0 0 0 1 0 2 7 5 8 ...

6 years ago | 0

Answered
removing specific values in a cell array
>> A = {1:10,1:10}; % square brackets are not required. >> F = @(a)a(a>=3&a<=8); >> B = cellfun(F,A,'uni',0); >> B{:} ans = ...

6 years ago | 1

| accepted

Answered
convert a cell array to 3-d array
B = permute(cat(3,A{:}),[3,1,2])

6 years ago | 1

| accepted

Answered
How do I split cells in an array and save data into a bigger cell array?
Use a comma-separated list to help concatenate them into one cell array or string array: >> arr = {'hello i welcome you';'what ...

6 years ago | 0

| accepted

Answered
cover cell array into vector
Numeric arrays do not have empty elements: every element has one value. But you can easily store the sizes and recreate the cel...

6 years ago | 0

| accepted

Answered
Removing loaded variables from workspace after changing name with eval
Do NOT use eval for such trivial tasks as importing data. Either access the fieldname, e.g. S = dir('C:\MyFolderPath'); N = n...

6 years ago | 0

| accepted

Answered
Replacing values in cell array in for loop
It is simpler and more efficient to use max: F = @(m) max(m,spect_threshold); Y = cellfun(F, Y, 'UniformOutput', false);

6 years ago | 0

| accepted

Load more