Réponse apportée
Is there a MatLab online training course that teaches you how to create and use functions?
There is a module in the Matlab Fundamentals online training that concentrates on functions: https://matlabacademy.mathworks.co...

presque 3 ans il y a | 0

Réponse apportée
finding a numeric pattern in a vector
Note that I added an additional test at the end of vec to make sure this handles a multi-digit number in the middle position of ...

presque 3 ans il y a | 0

Réponse apportée
How to extract specific dates from a datetime table?
whos('-file', 'DATE1.mat') whos('-file', 'DATE2.mat') load('DATE1.mat') load('DATE2.mat') whos head(datet) head(B) found_...

presque 3 ans il y a | 2

| A accepté

Réponse apportée
How do I use xline() to plot values calculated in a for loop?
Your x is going to be symbolic based on the code you posted (you can verify this by using the whos in the Command Window or by l...

presque 3 ans il y a | 0

| A accepté

Réponse apportée
What is the previous syntax for this function?
The strcat function has been around for a long time. strcat("Hello", "World")

presque 3 ans il y a | 0

| A accepté

Réponse apportée
output of two function results
You need to provide two output variables when you call the function. Note that the names you use when you call the function don...

presque 3 ans il y a | 1

Réponse apportée
Why are values not rotated?
P = [1 2]*10^7; % made up data to test with S = [1 2; 2 3]; T = [0 70; 0 100]; plot(S(1,:),T(1,:), S(2,:), T(2,:...

presque 3 ans il y a | 0

| A accepté

Réponse apportée
Calculate the temperature distr
First of all, format your code (type Ctrl-A then Ctrl-I) in the Matlab editor. Second, add more comments. For example, is m ...

presque 3 ans il y a | 0

| A accepté

Réponse apportée
Factorial using a for loop
Your code works fine (though I would add semicolons to the end of all lines except the for and end to avoid spewing a bunch of s...

presque 3 ans il y a | 2

Réponse apportée
read several csv files with space in the name format
i = 1; filename2 = strcat('opt.w.matrix.reg. ',int2str(i),'.csv') As you have seen, strcat strips leading and trailing spaces....

presque 3 ans il y a | 0

| A accepté

Réponse apportée
remove decimals from title when using sprintf
Q=2021; %year x = 0:10; y = x.^2; plot(x,y) grid on title(sprintf('text %d',Q)) % <<< replace %f with %d

presque 3 ans il y a | 0

| A accepté

Réponse apportée
Error using .^ not enough input arguments
Perhaps you meant this instead % L = integral( sqrt(1+{power(dy/dx),2}),x1,x2); % ^ ^ remove...

presque 3 ans il y a | 0

| A accepté

Réponse apportée
Most readable syntax to fill table in a for cycle
There probably isn't a significantly cleaner way to do this. See below for a way to suppress the warnings. format short e x =...

presque 3 ans il y a | 0

| A accepté

Réponse apportée
How do i do x1<=x<=x2 in matlab?
You have to split up the compound condition into two conditions: (x1 <= x) && (x <= x2) If these terms are scalars, that will ...

presque 3 ans il y a | 0

| A accepté

Réponse apportée
Formatting read data from text files
text_data = fileread('Question.txt'); disp(text_data)

presque 3 ans il y a | 1

| A accepté

Réponse apportée
How can I save an animated plot as a GIF?
Check the answer to this question: https://www.mathworks.com/matlabcentral/answers/94495-how-can-i-create-animated-gif-images-i...

presque 3 ans il y a | 0

Réponse apportée
animated sine wave continously
This should get you started. Adjust as desired. Note that the animation won't show here, but I tested it my local copy of Matl...

presque 3 ans il y a | 0

| A accepté

Réponse apportée
saving workspace variables individually?
a = 1; b = 2; c = 3; vars = who for v = 1:numel(vars) save(sprintf('%s.mat', vars{v}), vars{v}) end dir

presque 3 ans il y a | 0

| A accepté

Réponse apportée
Color in plot from Table
Just a couple of issues. You need column vectors to insert into the table, and you can only have a scalar string or char vector...

presque 3 ans il y a | 0

Réponse apportée
Convert C code to Matlab code for reading binary file
Your Matlab struct doesn't match the definition in the C code. For example, the third element is a char array of 100x1000 in th...

presque 3 ans il y a | 0

Réponse apportée
Saving a structure array, not fields of it
s1 = struct('a', 1, 'b', 2') save('s1.mat', 's1') % don't use the '-struct' option clearvars whos load('s1.mat') whos Anot...

presque 3 ans il y a | 0

| A accepté

Réponse apportée
Find column number for every row in matrix
A = [ -1 4 1 1 -1 -1 -5 4 -1 ]; [row, col] = find(A > 0) [~,idx,~] = unique(row, 'first...

presque 3 ans il y a | 0

Réponse apportée
Plot colored angle between two lines on the YZ plane
This doesn't look exactly like what you want, but should get you started. meta = [14.97, 29.84, 5.61]; meta_plan1 = [15, -10, ...

presque 3 ans il y a | 1

| A accepté

Réponse apportée
I have a problem with butter filter and I can’t fix it
The error was because you were trying to set the cutoff frequency at the Nyquist frequency (half the sample rate). The error me...

presque 3 ans il y a | 0

| A accepté

Réponse apportée
Simple loop with equation problem
Time(1) = [0]; Quantity(1) = 0.2; % Corrected initial condition Xt1 = 0.2; a = 0.5; t = 9; for i=1:t Xt1 = a * Xt1 * ...

presque 3 ans il y a | 0

| A accepté

Réponse apportée
How to use isoutlier based in a part of the data?
It seems like what you are wanting to do is to chop off the "increase at the end". Here is one way to do that by searching back...

presque 3 ans il y a | 1

Réponse apportée
reading serial COM port on the fly (weighting scale -> WinPC)
The serial object overload of fopen doesn't have any output arguments, so change that line of code to the following. fopen(p) ...

presque 3 ans il y a | 0

Réponse apportée
Plotting different color points based on array values
x = linspace(0, 10); y = sin(x); % test data yhi = y; ylo = y; threshold = 0.5; idxlo = y <= threshold; idxhi = y > thresh...

presque 3 ans il y a | 1

Réponse apportée
How to bring a patch to the bottom of a figure?
The code you originally posted already had the lines on top. Just plot the lines after the patch. hold on c = fill([0 4 5 2 1...

presque 3 ans il y a | 2

Réponse apportée
Not enough input arguments
Perhaps you have added the control system toolbox since last time this worked? That toolbox contains a function named pid that ...

presque 3 ans il y a | 0

Charger plus