Réponse apportée
Finding a variable in a large table
Here's a simple example, which I think you could extend to your situation % make an example table name = {'fish','cat','dog','...

environ 3 ans il y a | 0

Réponse apportée
How to build a function to make a working code more flexible?
The first thing you should do to greatly simplify your code and make it more flexible is to avoid using variable names with nume...

environ 3 ans il y a | 0

| A accepté

Réponse apportée
Matlab doesn run the program , says at the editor 'input argument might be unused ' for t
If you have your odefun stored in it's own .m file then the syntax for calling ode45 is just [t,x]=ode45(@odefun,tspan,x0); F...

environ 3 ans il y a | 0

Réponse apportée
I am trying to model solutions to a harmonic oscillator in physics using matlab and get "Array indices must be positive integers or logical values"."
The indices you are using in the expression x_array(t/dt+1) etc are not integers. MATLAB indexes arrays using either integer or...

environ 3 ans il y a | 0

Réponse apportée
Two functions having the same name but one being capital?
While MATLAB is case sensitive, Windows (assuming that is your operating system) is not. Since MATLAB requires that function nam...

environ 3 ans il y a | 0

| A accepté

Réponse apportée
Help to plot a frequency response of a function
Here is a basic approach (not using any toolbox functions for frequency response), that might give you some ideas of how this ca...

environ 3 ans il y a | 1

| A accepté

Réponse apportée
why the coefficient of case 2 is 2 columns, not 5 columns? (about coefficient value of PCA)
By default pca gives the 'economy' option which only includes significant components. for pca(X) with X n by p using 'economy' ...

environ 3 ans il y a | 1

| A accepté

Réponse apportée
How can I generate a pseudo random column vector V
Yes this will make a random column vector of length N at each iteration. The values will be uniformly distributed between 0 and...

environ 3 ans il y a | 0

Réponse apportée
Can someone help me open a Simulink file from an old version of matlab? (probably around year 2000)
I am able to open old Simulink .mdl files from around 1999-2000 using my MATLAB Simulink R2022b without taking any specific acti...

environ 3 ans il y a | 0

Réponse apportée
Saving the timestamp for each iteration in an array
You had numerous errors in your code. A key one is that you were writing the sensor data and time to the same column (B1). Since...

environ 3 ans il y a | 0

Réponse apportée
How to get z transfer function from difference equation?
I don't think there is any direct way to convert a difference equation to a transfer function in MATLAB. Maybe it is possible wi...

environ 3 ans il y a | 1

Réponse apportée
Find the set of eigenvectors of a 4x4 matrix elements whose matrix elements have some VARIABLE PARAMETERS.
If I understand what you are trying to do I think this should do what you want. The resulting values of the eigenvector for eac...

plus de 3 ans il y a | 1

Réponse apportée
How can i plot this function? y=0.75/(log10(x)*2).^2
Something like this? x = linspace(1,10); % or whatever interval you would like change accordingly y = 0.75 ./(log10(x).^2).^2 ...

plus de 3 ans il y a | 0

Réponse apportée
Why do I receive "Index exceeds the number of array elements. Index must not exceed 7." when trying to remove indices that are followed directly by a zero using a for loop.
Your loop variable x goes from 1 to the length of the vector. In line 4 you try to assign vec(x+1), on the last iteration x = l...

plus de 3 ans il y a | 0

Réponse apportée
Only the initial graph shows up
The problem is that you have an error in your line Error using legend Invalid argument. Type 'help legend' for more informatio...

plus de 3 ans il y a | 1

| A accepté

Réponse apportée
How to simplify code with multiple variable names?
You can use arrays to hold your data. So one approach would be to use arrays: ma - n by 1 ea - k by n r - n by 1 ir n by 1 ...

plus de 3 ans il y a | 0

| A accepté

Réponse apportée
Hello, I need help with: Replace elements in Vector A with those of vector B of the same position, only if they meet a certain condition, otherwise replace by a zero. Thanks
I like @Torsten's one liner and use of the multiplication times the logical zeros to null out the values where B is greater than...

plus de 3 ans il y a | 0

| A accepté

Réponse apportée
My loop does not produce the results I want, due to coding errors
I have made numerous corrections in your code. I think this is now at least closer to what you want clc; clear; x0 = 0; y...

plus de 3 ans il y a | 0

| A accepté

Réponse apportée
How to plot many figure with For function?
Uncomment the line in your code that assigns the figure number So for i=1:20 figure(i) plot(array(:,1),array(:,i)) end

plus de 3 ans il y a | 0

| A accepté

Réponse apportée
How to solve a system of two linear equations in matrix form under a loop /
I'll assume you know how to calculate A and B based upon your c and T values. Then to solve for X use X = M\(J*A + B) Note tha...

plus de 3 ans il y a | 0

Réponse apportée
Bode diagram for a Butterworth filter
What specific problems or errors are you getting? Here is an example that maybe you can adapt to your situation fs = 1000; % sa...

plus de 3 ans il y a | 0

Réponse apportée
function for cell array
Here's a simple example % Make an example cell array with a vector in each cell A = cell(2,3); % preallocate for i = 1:2 ...

plus de 3 ans il y a | 0

| A accepté

Réponse apportée
Write a function largest () such that it can accept multiple numbers and return the largest item from the given list.
There is already a MATLAB function that "can accept multiple numbers and return the largest one" x = [2,15,23.7,91.4,80.3] % ve...

plus de 3 ans il y a | 0

Réponse apportée
How can I plot a curve while changing color every N points ?
I was coding up the example below, and by the time I posted I saw you already had an answer from @Cris LaPierre. I will still in...

plus de 3 ans il y a | 0

| A accepté

Réponse apportée
fprintf for ~million row string matrix
You could try writecell and see if that is more efficient.

plus de 3 ans il y a | 0

Réponse apportée
Plotting multiple .txt files
You could do something like what is shown in this simplified example % Get a list of all of the text files list = dir('*.txt...

plus de 3 ans il y a | 1

Réponse apportée
Loading .log data with different number of columns
Yes, I would also recommend readcell, so for example logdata = readcell('Example.log','NumHeaderLines',2) You could then mak...

plus de 3 ans il y a | 0

Réponse apportée
How can I use the ( nchoosek ) for this case nchoosek(x,y) where x=[1:1:80] , and y=64;
Using b = nchoosek(80,64) You will see that there are approximately 2.6958 E16 ways of choosing 64 elements out of your vecto...

plus de 3 ans il y a | 0

Réponse apportée
I have a 4 Dimensional Matrix and i want to get its transpose
You can use the MATLAB permute function for this and not use any loops https://www.mathworks.com/help/matlab/ref/permute.html

plus de 3 ans il y a | 1

Réponse apportée
Modelling a variable (i.e. nonlinear) capacitor in Simulink: how to make it stable?
It looks like you may be using some circuit block set that I don't have available, however just going back to fundamentals you c...

plus de 3 ans il y a | 0

| A accepté

Charger plus