Respondida
how to fix 'Error using * Inner matrix dimensions must agree.' help please
Your 'angle' and 'speed' variables are strings you use for the input prompts. They are not the user inputs, which are x and y. S...

alrededor de 8 años hace | 0

Respondida
How can I tag each variable name in a .mat file with a trial number?
Please, please, please don't do this! It will be very hard to use those variables downstream in your code without a lot of nasty...

alrededor de 8 años hace | 1

Respondida
Matlab incorrectly reading a binary file
Please show the Fortran code that was used to write the file, and also the Fortran code that correctly reads the file. Depending...

alrededor de 8 años hace | 0

Respondida
I'm not sure how to set the stop criterion in the bisecting method
Inside the loop you can use this: if( abs(a-b) <= epsilon ) break; end Where epsilon is a value you set prior ...

alrededor de 8 años hace | 0

| aceptada

Respondida
Removing matrix rows in while-loop
In general, you should not remove rows in a loop. Instead, keep track of which rows you want to delete and then delete them all ...

alrededor de 8 años hace | 1

Respondida
Hi, can you help me!!! I 've got a problem when i went to calculate this matrix:
You need to tell MATLAB how many 0's are being concatenated in the upper right corner. E.g., A = [Aa zeros(size(Aa,1),size...

alrededor de 8 años hace | 0

Respondida
Finding the area under a polynomial equation in MATLAB
Just integrate the polynomial and evaluate at the endpoints. E.g., IB = polyint(B); area_under_poly = polyval(IB,X(end))...

alrededor de 8 años hace | 1

Respondida
Eliminate zeros from array
AT = reshape(A',1,[]); BT = reshape(B',1,[]); B = BT(AT~=0); A = AT(AT~=0);

alrededor de 8 años hace | 0

Respondida
when I add two floating point numbers the result is not correct above 262144
The amount you are adding, 0.01, is less than the eps of the number you are using. E.g., >> a = single(262144.000) a = ...

alrededor de 8 años hace | 0

| aceptada

Respondida
mxUnshareArray doesn't seem to work
I haven't forgotten this Question, but I don't know enough to completely answer it yet. That being said, I will give it a start ...

más de 8 años hace | 0

Respondida
How can I speed up the multiplication of matrices?
Q1: Why do you pre-allocate a bunch of 6000x6000 full matrices for d11, d12, and d22 only to downstream use sparse( ) on them an...

más de 8 años hace | 0

Respondida
How do i calculate the inverse of a non-square matrix?
Typically one would use backslash \ or perhaps pinv( ) for this. What are you using this for? I.e., what is the problem you are ...

más de 8 años hace | 0

| aceptada

Respondida
Create a pseudo-random array with a set probability of similarity to an existing random array
E.g., n = numel(array1); % total number of elements n2 = floor(n/2); % half of them x = randperm(n,n2); % random posi...

más de 8 años hace | 0

Respondida
How to make sure that ratios of very large numbers(e^1000+1)/(e^1000-1) is not given as NaN?
You can use an alternate formula for the large values: T = (1 + 1./exp(x)) ./ (1 - 1./exp(x)) Note that once x gets larg...

más de 8 años hace | 1

| aceptada

Respondida
Hello I have to write a code for the following second order ODE: d^2/dx^2=7x-8x^2+2y. This is what I have so far but I keep getting- Attempted to access y(2); index out of bounds because numel(y)=1. I would appreciate some help
Here you got the states set up in rows: y(1,:) = y0(:); Yet here you have the call made as if the states are in columns:...

más de 8 años hace | 0

Respondida
How can I write a Matrix with different elements by typing in a single command?
By putting it all on one line: [0 0 0 0 0; 0 0 1 10 20; 0 0 2 8 26; 0 0 3 6 32] But why do you need it on one line? The...

más de 8 años hace | 0

Respondida
Cant execute my nested sub-functions
You need to put code in your primary function to call the subfunctions to create the tables. E.g., function []=temperature_...

más de 8 años hace | 0

| aceptada

Respondida
Operations between matrix, different calculation according to conditions.
Cs(:,1) = (fs-.85*21*(d<c)).*As/1000;

más de 8 años hace | 2

Respondida
Problem to solve exponential equation
Why not solve it directly: x = 1./log(b) What's the point of using vpasolve for this?

más de 8 años hace | 0

Respondida
No performance improvement with preallocating for object arrays
Pre-allocation of variables means different things depending on the variable class. *(1) Numeric, char, and logical classes:...

más de 8 años hace | 1

Respondida
Shuffling non-zero elements of each column in a matrix
You're probably going to need a loop for this since the number of non-zero elements in a column is not constant across all the c...

más de 8 años hace | 1

| aceptada

Respondida
Solution for getting only one variable equal to 1 while other two variables 0.
E.g., if I understand your request: n = 3; % number of elements to use for k=1:n x = zeros(1,n); x(k) = 1;...

más de 8 años hace | 0

| aceptada

Respondida
How to select some columns from a no of columns uniformly in MATLAB ?
M = original matrix result = M(:,randperm(size(M,2),200)); If you need the columns to be in the same order as the origin...

más de 8 años hace | 0

Respondida
How to run predefined user inputs for a script inside a script?
Is this what you want? %script2 if( ~exist('X1','var') ) X1 = input('enter a value for X1: ') end if( ~exis...

más de 8 años hace | 0

Respondida
How do I code matlab to recheck while loops before continuing?
Maybe something like this logic is what you need, although you don't specify a way to get exe set to 0 so you would have to add ...

más de 8 años hace | 0

Respondida
Having trouble getting function to return two values
Your code has a path where nothing gets assigned to the output variables. Also, even for the path that does assign the output va...

más de 8 años hace | 0

Respondida
How to use Euler method with IVP with function of x and y?
3x is not a valid MATLAB expression. You need to have the multiplication operator between the 3 and the x. Also, you need to use...

más de 8 años hace | 1

| aceptada

Respondida
How to count the number of consecutive repetitions of an array?
E.g., [r,s] = runlength(A,numel(A)); result = r(logical(s)); You can find runlength on the FEX: <https://www.mathw...

más de 8 años hace | 1

| aceptada

Respondida
Physics problem help!
So, I will give you a start for an Euler scheme. You have two states to keep track of, the position and the velocity. Define two...

más de 8 años hace | 0

Cargar más