回答済み
Beginner coding; my second, simpler approach at trying to make all elements distinct.
FYI, to generate random integers you can use the randi( ) function instead of ceil(value*rand( )): https://www.mathworks.com/he...

4年弱 前 | 0

回答済み
How to make a "page transpose" in a 3D matrix without using the function pagetranspose?
Mtranspose = permute(M,[2 1 3]);

約4年 前 | 2

| 採用済み

回答済み
How to multiply an inverse matrix (nxn) by an array (nx1) using for loop
Not sure why you have a for-loop at all. Maybe you can explain this. If you just want to multiply the explicit inverse by a vect...

約4年 前 | 0

回答済み
Adding numbers to an array
You don't really need both h and hnew. Just use h and some indexing. E.g., h = zeros(1,45); % allocate expected result k = 1; ...

約4年 前 | 0

| 採用済み

回答済み
rounding issues in matlab, need to force values to 0
Instead of if abs(y1)< 1e-6 y1=0; end try y1(abs(y1)<1e-6) = 0;

約4年 前 | 2

| 採用済み

回答済み
why will the area only work for the circle and not the other shapes
To compare strings, do not use the == operator which does an elementwise compare. Instead, use a function meant for comparing st...

約4年 前 | 0

回答済み
if loop error in MALAB
Change your test to if isempty(n)

約4年 前 | 0

| 採用済み

回答済み
Index exceeds number of array elements
I think you want this for i = length(t)-1 to be this instead for i = 1:length(t)-1 The way you have it currently coded, ...

約4年 前 | 1

回答済み
Calling a Matlab function in Fortran
You have two fundamental errors with this code. You do not use the correct variable type for my_x, and you cannot call mexCallMA...

約4年 前 | 0

回答済み
MATLAB's inefficient copy-on-write implementation
See Loren's Blog on this topic. Basically, to write functions that can modify a variable "inplace" you need to call that functio...

約4年 前 | 1

| 採用済み

回答済み
How to multiply one array to all elements of a vector with a different size?
You can use implicit expansion with the element-wise multiply operator: c = a .* reshape(b,1,1,[]);

約4年 前 | 0

回答済み
sprintf, round-off, floating point bug?
I don't have all the versions installed necessary to investigate all of the results posted above, but this may simply be a "ROUN...

約4年 前 | 0

回答済み
how to save a figure plotted with matlab with best quality in .ppt or .pdf file?
See this FEX submission by Yair Altman: https://www.mathworks.com/matlabcentral/fileexchange/23629-export_fig?s_tid=srchtitle ...

約4年 前 | 0

| 採用済み

回答済み
how to read and write half precision arrays via mexFunction
Very unfortunately, MATLAB has implemented the half precision data type as an opaque classdef type instead of a simple numeric t...

約4年 前 | 0

回答済み
how to write mex function when input is a matlab function
This can be done, but it will not be efficient. The basic problem is that C/C++ doesn't understand anything about MATLAB functio...

約4年 前 | 0

回答済み
Is it possible to process the sparse matrix faster with vectorization instead of for loop?
You need to re-evaluate how you are doing things. In the first place, you have the Euclidean calculation wrong. It should be thi...

約4年 前 | 0

回答済み
How to exchange data between two C++ MEX files
Your current scheme is not foolproof. How does the 1st mex function know when it is safe to unlock and clear memory? How does th...

約4年 前 | 0

| 採用済み

回答済み
How to solve Lc=y without backslash operator?
First, I am assuming there is a typo and the system you are solving is Ly = c, not Lc=y. Second, you made a good start by writi...

約4年 前 | 0

回答済み
I am using euler's method to solve a differential equation, but when I run the code it doesn't plot.
Take a look at these lines: t0=0; %start time t1= 500; %finish time dt = 100000; Your stepsize is much larger than the total...

約4年 前 | 1

| 採用済み

回答済み
Accessing struct using C library always NULL
Typically, it is best just to post your code so we can see exactly what you are doing, instead of posting a description of your ...

約4年 前 | 1

| 採用済み

回答済み
Errors while trying to setup equation for root finding.
Did you mean multiply by the "a"? x_pdo = z_pdo/(1 + a*(k_pdo - 1)); x_water = z_water/(1 + a*(k_water - 1)); x_glycerol = z_...

約4年 前 | 0

回答済み
How do I access a field from a function's input?
Assuming you are passing in a character string for freq, use this syntax: output = myStruct.(freq);

約4年 前 | 0

| 採用済み

回答済み
How can I obtain the T and Y for R Runge Kutta method?
The first version has an error. This line: k3=h*feval(f,T(j),Y(j)); should be this instead: k3=h*feval(f,T(j)+h/2,Y(j)+k2/2);...

約4年 前 | 0

回答済み
How to solve array indices error?
x1 = 0*ft; : distance1=sqrt((x1-x2)^2+(y1-y2)^2+(z1-z2)^2); : sp = distance1(x1,y1,z1,dx,dyv(i),dz); % incident di...

約4年 前 | 0

回答済み
Solving ODE using Euler Method and 4th Order Runge Kutta Method
You pretty much have the Euler scheme worked out, so I will help you with a vector formulation. Take this code: for i=1:n ...

約4年 前 | 0

| 採用済み

回答済み
Problem finding sum of array using vectorization
The first element of x is 1, so that element produces 1/(1-1) = 1/0 = inf in the second line. You need to rewrite that second li...

約4年 前 | 0

回答済み
Multiplication of large matrix with its transpose
The fastest way is to simply write it as A * A', because MATLAB will see that the operands are the same and call a special multi...

約4年 前 | 0

回答済み
Solving ODE in MATLAB using Runge-Kutta method of order 4
Why aren't you using this to update z: z(i+1) = z(i) + (1/6)*(l1+(2*l2)+(2*l3)+l4);

約4年 前 | 0

回答済み
Why is the string type not implemented as standard type?
All of the standard full numeric types as well as char and logical are implemented as simple rectangular data arrays. The string...

約4年 前 | 1

回答済み
how to print randomly selected column?
Shouldn't that be size(data,2)? Also, generally you should be using string comparison functions for the tests, not the == opera...

約4年 前 | 0

さらに読み込む