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

Answered
How do I create a "function function"? How do you make a function that accepts another arbitrary function as an input argument?
_'... a special type of function in MATLAB called a "function function".'_ There is nothing special about a function that acc...

8 years ago | 0

| accepted

Answered
comparing values and using the results
_"how will i write a code that will automatically compare and give a result saying a particular code is strongest"_ By changi...

8 years ago | 0

Answered
How to save a text file as a .mat file?
M = csvread('oldfile.txt'); save('newfile.mat','M')

8 years ago | 1

Answered
Not enough input arguments
Read the documentation. The <https://www.mathworks.com/help/signal/ref/ss2sos.html |ss2sos|> help clearly lists all of the synta...

8 years ago | 0

| accepted

Answered
allocate values avoiding loop
Some indexing using the first column does what you want, more efficiently than a loop or |unique|: >> M = [1,1,-1.1471;1,2,...

8 years ago | 1

| accepted

Answered
While loop is not recognizing a defined variable
_"While loop is not recognizing a defined variable"_ Because that variable is _not_ defined. You clear |To6| several time...

8 years ago | 0

Answered
How to horizontally concatenate the cells of a cell array with different contents into a string.
An old-fashioned way (strings are probably easier): >> C = {550,2,'GAM';600,2,'GAM';650,2,'GAM';700,2,'GAM';750,2,'GAM';800...

8 years ago | 0

Answered
A=[1 2;n 5;3 5;6 8] .......... very long matrix i want do a condition for reed my rows and when he find a character he delet this rows B=(315151,3) very long matrix expmple reed if you have a character do delet this rows
This reads your sample data file (attached) into a numeric matrix, ignoring the headers and empty lines: fmt = repmat('%f',...

8 years ago | 0

| accepted

Answered
How can I use resolve this error on the getslopeintercept function It worked well in the past (2014) for me but its yielding errors in the current Matlab version.
_"...It worked well in the past (2014) for me but its yielding errors in the current Matlab version."_ I would not assume tha...

8 years ago | 0

Answered
fprintf break line different arrays
It is easier when you put your vectors into one cell array: C = {[1,2,3,4,5,6,7,8,9,10,11],[12,13,14,15,16]}; F = [repma...

8 years ago | 0

| accepted

Answered
Matrix manipulation problem under MATLAB
Storing scalar numerics in cell arrays will make your processing pointlessly complex, so I will presume that you actually sensib...

8 years ago | 0

| accepted

Answered
Why array only saves last run of results from nested FOR Loop?
_"I created a for loops..."_ Yes, you did. _"...and store values for each loops in array."_ No, you did not. _"Could...

8 years ago | 1

| accepted

Answered
how to make a sorting line by line?
Here are two methods that match <https://www.mathworks.com/matlabcentral/answers/428610-how-to-make-a-sorting-line-by-line#comme...

8 years ago | 0

| accepted

Answered
Why is nothing coming up on my plot?
MATLAB is a high-level language, so forget about loops and use logical indexing: x = -5:0.01:5; y = -10+zeros(1,numel(x)...

8 years ago | 1

Load more