Answered
What mistake I am making?
Using a loop: function [avg] = avgpositive7multiples_for (m) s = 0; a = 0; for t = 1:length(m) if m(t) > 0 && mod(m(t),...

5 years ago | 0

| accepted

Answered
loop storing only the last value, I want all values of the loop to be stored
Note that your assignment to Ts is independent of the loop iterator a, so each time through the loop Ts is assigned the contents...

5 years ago | 1

| accepted

Answered
Create a script file using control flow statements that returns all the prime numbers from 2 till hundred.
This solution does not use any control flow statements: numbers = 3:100; prime_numbers = numbers(isprime(numbers)); This solu...

5 years ago | 0

Answered
What is this peak's meaning?
It means that the magnitude of the Fourier transform of this rainfall data has a local maximum at that frequency.

5 years ago | 0

Answered
Create a cicle 'for' to create multiple fields
data = struct(); fn = {'C028' 'C022' 'C008' 'C006'}; for i = 1:numel(fn) data.(fn{i}) = getfield(importdata([fn{i} ' S1.m...

5 years ago | 1

| accepted

Answered
Madlab iseqaul edit field
I assume the global variable xaxis is a character vector, since it is being used in xlabel like one. If it is, then isequal(xaxi...

5 years ago | 0

Answered
how to calculate the area binary if some images have different pattern
You will have to adjust your code to handle cases when the number of regions in an image is not 4. In particular, the line for ...

5 years ago | 0

Answered
How to change the fontsize of labels not axsis.
Try replacing those four lines of code with the following: h.FontName = 'Times New Roman'; h.XLabel.String = 'Angular(rad)'; ...

5 years ago | 0

Answered
I want to chose a function and use it in the code, but have the possibility to chose different functions, is it possible?
Try replacing your line with eval with the following: input_dpd = feval(baseStr,input_signal.x);

5 years ago | 0

Answered
How do I search for and collect column data based on column name?
name = 'AM'; subject = ["1.1_", "1.2_", "2.1_", "2.2_"]; Pos = ["LHS-LHS", "RHS-RHS"]; Search = {'LKneVel' 'LKneMom' 'LKneP...

5 years ago | 0

| accepted

Answered
Error: This statement is incomplete.
Pass j to sprintf three times instead of one: for j = 1:12 eval(sprintf('factor_2017_%d = trapz(year_2017_%d(:,4))/trapz(y...

5 years ago | 0

Answered
Convert Cell Array into equation
If C is a cell array containing a MATLAB expression in each cell, then the following code will evaluate the expressions and retu...

5 years ago | 0

| accepted

Answered
How to make the negative sign in the legend easier to see?
You can get some more space by using cell arrays in strcat (because strcat trims white space off the ends of character arrays): ...

5 years ago | 1

Answered
extracting values from a matrix
If M is your matrix, then block1 below will be a vector with all elements of M with value equal to 1, 2 or 3, in the order they ...

5 years ago | 0

Answered
No such file or directory for a found file.
files(n).name is just the file name, not the full path to the file, so you have to cd to the directory and/or refer to the file ...

5 years ago | 0

Answered
Porblem in exporting a txt file
Here's one way. This will collect the first three columns of each section into a cell array called data, each element of which c...

5 years ago | 0

| accepted

Answered
Correct way of using if-Function
The problem is that you are using the index i instead of v1(i) (or maybe it should be v2(i) - no way to tell) in your comparison...

5 years ago | 1

Answered
Matlab and Fortran Precision Issue
The value of F1 is different in MATLAB vs Fortran.

5 years ago | 0

Answered
help regarding for loop
Axb=[1 1 1 2 1 5 7;1 2 2 1 1 3 6;1 3 3 0 1 6 6;1 2 2 2 2 3 -8;1 1 1 1 1 6 8;3 5 9 3 4 3 1;2 2 5 1 8 9 5]; z = Axb(1,:); z(2,...

5 years ago | 1

| accepted

Answered
I don't understand this error in Matlab 2021a: Error using slice (line 65) V must be a 3-D array.
This error happens because fcw is not a 3-D array. You should inspect flux.data to see if it's what you expect.

5 years ago | 0

| accepted

Answered
Guide: panels and visibility
It sounds like the uicontrols you want to hide are not children of the panel (i.e., are not contained in the panel), so they don...

5 years ago | 0

Answered
How do I change the color bar scale
To set the colorbar scale to [36 45], add the following line at the end of your code: set(gca,'CLim',[36 45]); This will turn ...

5 years ago | 1

Answered
Separte Matrix depending on changing value in column
Let X be your N-by-2 matrix. Then the following code will separate X into a cell array Y, each element of which is a slice of X ...

5 years ago | 0

| accepted

Answered
finding numbers below a threshold and doing calculations on them
idx = T(:,4) > 0.13; % similarly for other thresholds ResV(a) = mean(sqrt(sum(T(idx,2:4).^2,2))); In your original code, note ...

5 years ago | 0

| accepted

Answered
Sampling pixel intensities according to distance matrix...
Let X be your matrix of distances and Y be your matrix of intensities. Then the following code makes use of logical indexing to ...

5 years ago | 0

| accepted

Answered
Splitting a row matrix to different rows
Here's one way, if I am interpreting your method correctly: B = [repelem(A(:,1),size(A,2)-1) reshape(A(:,2:end).',[],1)];

5 years ago | 0

| accepted

Answered
My graph won't plot
Your expression for f contains matrix division (/), which causes f(x) to return a scalar, so the vectors you're plotting (x and ...

5 years ago | 0

Answered
reshaping multiple data sets
The error happens because vel is not a cell array. To keep the result from each iteration of the loop, you can make Out a matri...

5 years ago | 0

Answered
How to create a square matrix based on user input,then show it with surf command and it have to repeat until user write same m and n matrix inputs.
You should initialize a before your for loops: a = zeros(m,n); Then you don't need to call reshape at all.

5 years ago | 1

| accepted

Answered
Scan a row and replace any values equal to zero
cA(i+1,cA(i+1,:) == 0) = 1E-07;

5 years ago | 0

| accepted

Load more