답변 있음
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 ...

대략 8년 전 | 0

| 수락됨

답변 있음
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 ...

대략 8년 전 | 1

답변 있음
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...

대략 8년 전 | 0

답변 있음
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))...

대략 8년 전 | 1

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

대략 8년 전 | 0

답변 있음
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 = ...

대략 8년 전 | 0

| 수락됨

답변 있음
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 ...

대략 8년 전 | 0

답변 있음
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...

대략 8년 전 | 0

답변 있음
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 ...

대략 8년 전 | 0

| 수락됨

답변 있음
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...

대략 8년 전 | 0

답변 있음
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...

대략 8년 전 | 1

| 수락됨

답변 있음
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:...

대략 8년 전 | 0

답변 있음
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...

대략 8년 전 | 0

답변 있음
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_...

대략 8년 전 | 0

| 수락됨

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

대략 8년 전 | 2

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

대략 8년 전 | 0

답변 있음
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:...

대략 8년 전 | 1

답변 있음
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...

대략 8년 전 | 1

| 수락됨

답변 있음
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;...

대략 8년 전 | 0

| 수락됨

답변 있음
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...

대략 8년 전 | 0

답변 있음
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...

대략 8년 전 | 0

답변 있음
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 ...

대략 8년 전 | 0

답변 있음
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...

대략 8년 전 | 0

답변 있음
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...

대략 8년 전 | 1

| 수락됨

답변 있음
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...

대략 8년 전 | 1

| 수락됨

답변 있음
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...

대략 8년 전 | 0

답변 있음
code is showing error with some inputs
Why are you using v(1:1) as an index into v? Did you mean this instead? w = v(end:-1:1); Also, it is not clear from you...

대략 8년 전 | 0

| 수락됨

답변 있음
Confusion in using polyfit and polyval to predict data
Because that is the "time unit" used for your polyfit calls earlier in the code: nz_years_adjust=(nz_years-1900)/50; I.e...

대략 8년 전 | 1

| 수락됨

답변 있음
Conversion of seconds to date
MATLAB is giving you the result of June 16, 2010 because that is the correct answer for the input of 1907798400. This matches in...

대략 8년 전 | 5

| 수락됨

더 보기