Answered
How to count repetition of a row in a matrix?
>> M = [1,2; 2,3; 1,5; 2,3; 1,4; 1,6; 2,3; 8,9]; >> R = [2,3]; Method one: eq: and all: >> nnz(all(M==R,2)) ans = 3 For MA...

8 years ago | 0

| accepted

Answered
Saving or using callback values
The easiest way to do this is to use a nested function (which in this case is your callback function): function val = myfun() ...

8 years ago | 0

Answered
How to plot data from cell array based on a logical array?
Far too complex. You are trying to define strings which will be magically evaluated and converted back into data. The syntax yo...

8 years ago | 1

| accepted

Answered
I cant get my nested if statements to work, is the indentation wrong?
Your indentation is messed up. You should use the default indentation of the MATLAB editor: select all of the code press ctrl+...

8 years ago | 0

Answered
getting error for my program as " Error using * Inner matrix dimensions must agree." on line 42 . can someone help me resolve this issue?
The error occurs here: 1i*2*pi*(n3.*I0)*(Lnl./L)*((abs(E1)).^2) ^^^^^^^^^^^^^^^^ % scalar ...

8 years ago | 1

Answered
count the number of transitions from 0 to 3 in cells in cell array
Here is a simple method based on logcal arrays, demonstrated on two Nx4 matrices in a cell array. The first matrix has two 0,3 t...

8 years ago | 0

| accepted

Answered
Finding the max value of a particular row in a cell array and then returning the values of the full row in a table
>> S = {[1,2,3;4,5,6],[3,4,6;7,8,9]}; >> A = cat(3,S{:}); >> [~,idx] = max(A(1,3,:)) idx = 2 >> V = A(1,:,idx) V = 3 ...

8 years ago | 0

| accepted

Answered
why condition become true in if/esle ?
"...here Vxp and Vxn both are same value(32.000); so the difference must be 0..." Evidently not true. "why it's happening ? an...

8 years ago | 1

Answered
How can I get an average of different matrices stored as separate .mat files?
Assuming that each file contains exactly one variable (a matrix) and that all matrices are the same size and type: S = dir('*...

8 years ago | 2

| accepted

Answered
How do you pause rendering of a figure until you're done setting properties?
This might work: # Find its parent figure (e.g. |gcf|) and set its |'Visible'| property to |'off'| # Change the properties ...

8 years ago | 1

Answered
how to return the solution of a vector of variables one time instead of indexing sol.x1, solx2..etc
You can dynamically access fieldnames: <https://www.mathworks.com/help/matlab/matlab_prog/generate-field-names-from-variables...

8 years ago | 0

| accepted

Answered
How to store multiple column vector generated from a for loop?
N = 41; A = nan(12,N); B = nan(12,N); C = nan(12,N); D = nan(12,N); for k = 1:N [A(:,k),B(:,k),C(:,k),D(...

8 years ago | 0

| accepted

Answered
I'm stuck debugging a simple code. Maybe I'm making a mistake by assuming that there no difference between when MATLAB executes instructions in a script and when MATLAB executes instructions from the command window.
_"I run this simple script, entitled "proj3numan", written exactly as you see here:"_ Nope. That error message shows how you ...

8 years ago | 1

| accepted

Answered
How can i find Inverse of an array of non negative integers ?
>> G = [4,1,2,5,3] G = 4 1 2 5 3 >> [~,S] = sort(G) S = 2 3 5 1 4

8 years ago | 1

| accepted

Answered
How to erase newline character from string?
strtrim(text)

8 years ago | 4

| accepted

Answered
Using For Loop to find average of columns in a matrix
Using a loop, without |sum| or |mean|: X = randi(9,4,7) N = size(X,1); V = X(1,:); for k = 2:N V = V + X(k,...

8 years ago | 0

| accepted

Answered
fprintf a solution with two variables, one from a vector
*Solution:* fmt = 'The power produced by a 10m^2 wind turbine at velocity %1.0f is %.2f\n'; fprintf(fmt,[V;P1]) print...

8 years ago | 0

Answered
Can I create a code to avoid updating the struct every time I use a different struct?
If each mat file contains only _one_ variable (but its name changes and you don't know the name in advance) then you could just ...

8 years ago | 0

Answered
Matlab Problem with dot indexing
This happens because |gLabelData| is not a structure, which you code expects it to be. So why is |gLabelData| not a structure...

8 years ago | 0

| accepted

Answered
Help with loops _ multiple variables
Use indexing and vectorize the appropriate operations: Sm1 = [2;3;1;4]; Fc1 = [5;2;3;7]; A1 = [1;4;1;2]; Fs = 60...

8 years ago | 0

| accepted

Answered
How to construct the n*n matrices, like below:
Use <https://www.mathworks.com/help/matlab/ref/toeplitz.html |toeplitz|>: >> n = 10; >> toeplitz([2,-1,zeros(1,n-2)]) ...

8 years ago | 0

Answered
How do I extract an intermediate variable calculated and used inside my ode45 function?
_"I want to get the computed values of u at each time instant with t with x"_ The simplest solution is to add a second output...

8 years ago | 8

| accepted

Answered
How to delete the second struct from 2x1 (non-scalar)struct?
S = ... your structure S = S(1)

8 years ago | 0

Answered
find matching values from two unequal size arrays
>> A1 = [1,2,3;4,5,6;7,8,9] A1 = 1 2 3 4 5 6 7 8 9 >> A2 = [1,2;0,0;0,0;...

8 years ago | 0

| accepted

Answered
Having trouble with a short code in Octave... Complete beginner, So any help Welcome
% 1) M0 = [1,4,3,100,12,1000,25,32,500,700,20,9000,25,650,40,3,67,2,305,80,200,50,2,15,4]; M1 = [1,6,2,120,14,900,25,35,...

8 years ago | 1

| accepted

Answered
How to I create an Array of Operations?
It is not very clear what you want, but perhaps a cell array of function handles might help: >> C{1} = @() randi([100,500])...

8 years ago | 1

| accepted

Answered
How to delete lines before a particular character from .txt files?
A straight-forward line-by-line method: [fii,msg] = fopen('tdump18020910.txt','rt'); assert(fii>=3,msg) [fio,msg] = f...

8 years ago | 1

Answered
How can I read an excel file without approximating values to 4 decimal places?
MATLAB does not _"approximating values to 4 decimal places"_ when reading file data, that is simply how the values are being _di...

8 years ago | 0

| accepted

Answered
sort a cell array based on the number of rows in each cell
Your question is confused: you ask that you want to _"sort a cell array based on the number of rows in each cell"_, but then lat...

8 years ago | 0

| accepted

Answered
Changing a CSV file while keeping it readable by MATLAB
_'but then I can't save it in the same format.'_ Yes, you can. _'I can't use csvwrite because it's not in matrix format.'_...

8 years ago | 1

| accepted

Load more