Respondida
How to remove the first element and last element based on First column
Here's one way x1 = [1,293;... 1,274;... 1,329;... 1,348;... 2,237;... 2,374;... 2,32...

más de 4 años hace | 0

| aceptada

Respondida
How to select columns from data matrix using for loop?
partbin = reshape (pdp,24,[]); threshold = 0.0435; for i= 1:size(partbin,2) current_column = partbin(:,i); ...

más de 4 años hace | 0

Respondida
How to generate rectangles based on coordinates in a randomized matrix?
S.matrix(:,1) is a vector, so S.matrix(:,1) == 1 is a vector (of class logical) the same size as S.matrix(:,1). When that vector...

más de 4 años hace | 1

| aceptada

Respondida
I keep getting inf for Ru
Use element-wise division (./) in the expression for Vm. Also, it looks like the expression for Ru should have 1./(T+273) rather...

más de 4 años hace | 0

| aceptada

Respondida
how to increase two variables in a for loop at the same time
In general: theta_inf_1_values = 7:2:15; theta_inf_2_values = 15:-2:7; for ii = 1:numel(theta_inf_2_values) disp(ii) ...

más de 4 años hace | 0

| aceptada

Respondida
Multiply a number with a line of returns
v = [0.01 0.02 0.03 0.05 0.1 0.01 0.02 0.05 0.07]; P = 10; If you want the cumulative effect of each return: P*cumprod(1+v) ...

más de 4 años hace | 0

| aceptada

Respondida
How can I convert 3d MRI data (128x128x27) into 4d (128x128x1x27) for visualization using montage?
mri.mat is a .mat file included with the MATLAB installation that contains a few variables: which mri.mat S = load('mri.mat') ...

más de 4 años hace | 0

| aceptada

Respondida
Opening a Textfile in MATLAB Appdesigner Online
fopen merely opens a file so that subsequent code can read from or write to the file. To read the contents of a file into a var...

más de 4 años hace | 0

Respondida
Why does my loop stop after the first iteration?
Mn_A takes 2 input arguments, x1 and n: function r = Mn_A(x1,n) But later in the function Mn_A, you call Mn_A with one input: ...

más de 4 años hace | 1

| aceptada

Respondida
What is the equivalence for the Big M in MATLAB?
Sounds like you want Inf (infinity) % Inf is not the minimum of the vector, as long as there % are some finite number (non-In...

más de 4 años hace | 0

| aceptada

Respondida
How can I insert a while loop inside a for loop on Matlab without having to manually stop the run?
One thing is, you probably mean to have abs in the while condition. That is, say h1(i)-h1(i-1)==-1000 (and the same for h2, etc....

más de 4 años hace | 0

Respondida
help creating a matrix from data in a for loop.
hrs = 24; % 24 hours iterations = 60; % 60 iterations per hour data = zeros(iterations,hrs); % initialize data to be a 60-by-2...

más de 4 años hace | 0

| aceptada

Respondida
importing only one element of a matrix into a function
Yes, that's fine. (Try it and see.) The only thing I would point out is that you probably don't want to overwrite f each time, ...

más de 4 años hace | 0

| aceptada

Respondida
How can I copy lines of an external text file to another file
Here's one way: fid_in = fopen('a.txt'); % input file fid_out = fopen('b.txt','w'); % output file for ii = 1:4 % read (and di...

más de 4 años hace | 0

Respondida
How can I change the title of the subplots with forloop iteration?
subplot counts across the first row first, i.e., subplot(6,4,2) is the subplot in the second column of the first row (not the fi...

más de 4 años hace | 0

| aceptada

Respondida
How do I get an output in vector form of (h,m)
I'll assume that a vector of the form (h,m) means a column vector of Volume values, each element corresponding to an h and an m,...

más de 4 años hace | 0

Respondida
How to interpolate a matrix
data = randi(100,8) n = size(data,1); data_interp = interp1(1:n,data,linspace(1,n,11*(n-1)+1)) isequal(data_interp(1:11:end,:...

más de 4 años hace | 1

| aceptada

Respondida
Invert Y data (Y axis)
Do this: set(gca(),'YDir','reverse') at the end (or anywhere after imagesc).

más de 4 años hace | 1

| aceptada

Respondida
Only part of my plotted line will dash and how to add text to a line in the plot?
text requires 2 coordinates (x,y) or 3 coordinates (x,y,z) to specify the text location. You were supplying only one coordinate....

más de 4 años hace | 0

Respondida
How to find the average of y over a range of x?
% some times, x: x = 0:0.01:9 % some amplitudes, y: y = sin(x) % plot y vs x to visualize (see plot below): plot(x,y) ...

más de 4 años hace | 1

| aceptada

Respondida
How to output a large matrix to one excel with multiple sheets in specific size?
% a 289x52 matrix: xy = readmatrix('test100_4.4.22cellsmeetcriteria.xlsx'); % write each pair of columns (one x and one y) ...

más de 4 años hace | 0

| aceptada

Respondida
I need to prompt the user for a vector of any length and sort the numbers into prime, even or odd and display them.
The code as written will check whether x is prime only if x is not even and not odd. But if x is an integer, it's either even or...

más de 4 años hace | 0

| aceptada

Respondida
Adding unique values to an array
You can use ismember to check whether the new random number is already in the array of unique numbers: UNI = []; while numel(U...

más de 4 años hace | 0

| aceptada

Respondida
I get "Index exceeds the number of array elements (2)" error. Would appreciate any help.
This line: xmit = randi(P,1,M); makes xmit a 1-by-M vector of random integers, with values between 1 and P. With P=1000 and M=...

más de 4 años hace | 1

Respondida
how do i write function sin together with square root in matlab?
The square root function is sqrt 2*sin(sqrt(x))-x

más de 4 años hace | 1

Respondida
How to fix " --> " arrow like Data as result of read file function?
Those arrows represent tabs. In the file, the numbers are separated by a tab followed by one or two spaces, except before the 14...

más de 4 años hace | 1

| aceptada

Respondida
Splitting Cells Within A Cell Array
% some made-up data in the same format as yours: C = { {'Droo Breeze',157}; {'Thom Braadie',751}; {'Jo Mountaine',999}; {'Jon E...

más de 4 años hace | 0

| aceptada

Respondida
How do I change the legends font size but not the scale size on my geobasemap?
CTDlatlon = struct( ... 'Latitude',0.5*rand(1,5)+63.5, ... 'Longitude',3*rand(1,5)-42); mycmap = flipud(parula(leng...

más de 4 años hace | 0

Respondida
Change format number of output vector
Looks like maybe you have something like this: x = 1e4*[0.000150506971824 0.000475944834700 1]; format long x You can try ...

más de 4 años hace | 0

| aceptada

Respondida
Division by repeated subtraction with remainder
DbyS(4,3) Consider that the following lines of code: r = x; while r > y r = x - y; q = q + 1; end z = [q r]; app...

más de 4 años hace | 1

| aceptada

Cargar más