Answered
Have an error with dot, while searching value in struct
Dynamic field names do not support nested fields like that. But you can do it in two separate dynamic field name references: pa...

5 years ago | 0

Answered
Why is sec(theta) different than sqrt(1+tan(theta).^2) in MATLAB?
sqrt(x) returns the positive square root of a real number x. For example, sqrt(4) returns 2, but -2 is also a square root of 4. ...

5 years ago | 0

Answered
My precious scatter3 labels are mixed-up?
Note the order of the arguments in the call to scatter3: h=scatter3(Lab(3,:),Lab(2,:),Lab(1,:),80,RGB,'fill'); so x correspond...

5 years ago | 0

| accepted

Answered
i want to ask how can i store the value of d_eb for each iteration of loop
Case 1: If you want one d_eb value for each (x_e, y_e) point, you can initialize d_eb to be the same size as x_e and store each ...

5 years ago | 1

| accepted

Answered
how to create pyramid made of numbers between 0-9?
nr = 4; % number of rows specified nc = 2*nr-1; % number of columns required nd = 1+2*(0:nr-1); % number of digits on each r...

5 years ago | 0

Answered
Read Text files, subtract the columns of the text file and same in same text file.
You can use readmatrix to read the file. To do the arithmetic and storing the result in the same matrix, you can do something l...

5 years ago | 0

Answered
How to imread() an RGB image to a [3 rows by n columns] double form?
You mentioned you made attempts to use reshape and permute, which is the way I would do it. Does this: Lab_reshape = reshape(pe...

5 years ago | 0

| accepted

Answered
Keycode response and response times displaying 0
I believe this problem will be prevented by doing what I described in my answer to another question about this code. To explain...

5 years ago | 1

| accepted

Answered
Variable not getting created
Here is a copy of the code you posted, but with indentation: %creating random array of ones and twos to use to define condition...

5 years ago | 1

| accepted

Answered
Want to remove a line in my plot
You should change the calculation of X to be: X=(B(:,2)-A(:,2))./A(:,2); This does element-wise division rather than matrix di...

5 years ago | 0

Answered
understanding MATLAB method in long equation
The 1-sqrt(5) needs parentheses around it too.

5 years ago | 0

| accepted

Answered
textread function parameters help
As far as I can tell from reading the documentation for textread, those input arguments don't do anything special. They merely e...

5 years ago | 0

| accepted

Answered
Construct a single anonymous function from a cell array of anonymous functions
If f is a cell array of handles to functions that return a scalar result, then you can use cellfun and feval to achieve the resu...

5 years ago | 0

| accepted

Answered
For loop for equation
l=zeros(size(prob)); u=zeros(size(prob)); u(1,:)=1; l(1,:)=0; for i=2:length(u) l(i)=l(i-1)+(u(i-1)-l(i-1))*prob(i-1); ...

5 years ago | 0

Answered
How to concatenate matrices when some of them can be empty?
make the empty matrices 0-by-12, then you can vertcat them like normal. if isempty(T2) T2 = zeros(0,12); end % and so on...

5 years ago | 0

Answered
Why does Matlab put symbols out of order when using a matrix?
Some math (not MATLAB code): sin(C-A-B) = -sin(-(C-A-B)) % because sin is an odd function, i.e., sin(-x) = -sin(x) ...

5 years ago | 0

Answered
concatenate doubles of different sizes in a cell array into one double
my_cell = {rand(4,2) rand(7,2) rand(10,2)}; % make up some data reflecting your situation my_matrix = vertcat(my_cell{:}); % ve...

5 years ago | 0

| accepted

Answered
Plotting professional MATLAB graph of given two txt files
x = load('out1.txt'); y = load('out2.txt'); figure(); plot(x,y); xlabel('time'); ylabel('value');

5 years ago | 0

| accepted

Answered
Help needed finding sum of array of numbers that involves both subtraction and addition
The even terms are subtracted and the odd ones are added, so you need some logic that distingushes between even and odd terms an...

5 years ago | 0

Answered
Plot trajectory based on position/acceleration data
How about using plot3? figure(); plot3(s_x,s_y,s_z);

5 years ago | 0

Answered
Parsing unique .txt messages issue in matlab?!
fid_in = fopen('input.txt','r'); fid_out = fopen('perfect.txt','w'); fid_index = fopen('load_index.txt','w'); while true ...

5 years ago | 1

| accepted

Answered
How to generate a vector taking elements from a bigger one in a simple way
B = A([1 10:10:end]); % take the 1st, then 10th, 20th, etc., elements of A B = B(:); % make B a column vector regardless of the...

5 years ago | 0

| accepted

Answered
Index exceeds the number of array elements. Index must not exceed 0.
This happens because pks is empty, i.e., findpeaks returned no peaks. You will need to modify your code to handle this situation...

5 years ago | 0

Answered
How to find out standard deviation of a matrix when there is a lot of NaN values?
std(x,[],2,'omitnan') where x is your matrix, 2 tells std to go by row, and 'omitnan' tells std to ignore NaNs in x.

5 years ago | 1

Answered
New string based on parts of old string
OldStr1 = 'Extract clusters: PR (2 files) | DG_MD_CG_22'; OldStr2 = 'Extract clusters: OR (2 files) | AG_MD_HH_CG_HH_22'; Ne...

5 years ago | 0

| accepted

Answered
I have a phase plot in radians varying from 20 to 26 (a linear graph), how do i convert this plot from -pi to +pi or from 0 to 2 pi?
phases = 20:26 % phases going from 20 to 26 radians phases = mod(phases,2*pi) % the same phase values, now between 0 and 2 pi ...

5 years ago | 1

| accepted

Answered
trying to use a while loop to run through a list created by user inputs to plot one or multiple functions
prompt = 'please choose which funtions you want to plot. A, B, C, and/or D.'; g = (input(prompt,'s')); figure(); % all lines...

5 years ago | 0

| accepted

Answered
Index matrix changing values outside index to NaN
idx = [1,2,3,4,9,5,6,7]' data = [1.5, 4.2, 3.4, 5.6, 7.8, 6.2, 7.5, 5.2]' ND = numel(data) result = NaN(size(idx)) is_good...

5 years ago | 0

| accepted

Answered
I'm getting the inv error code saying it must be squared
inv takes the inverse of a square matrix (that is, a matrix with size n-by-n for some n). In this case you are trying to take th...

5 years ago | 1

Answered
How to change mat files in each iteration?
You can try this: file_name = 'doc3.mat'; file_name = [file_name(1:end-4) datestr(now(),'mmddyyyyhhMM') file_name(end-3:end)];...

5 years ago | 0

| accepted

Load more