Answered
How can I make all numbers in my matrix repeat?
hourly_data = 100*rand(24,1); iterations = 60; new_data = repelem(hourly_data/iterations,iterations,1);

4 years ago | 0

| accepted

Answered
Building a matrix model
You can use the second output from the min function to get the index where the minimum Wi occurs. Then use that index to get the...

4 years ago | 0

Answered
Why does Timer callback experience "too many output arguments" errors?
Specifying the TimerFcn like this: 'TimerFcn', app.refreshTick(), ... actually calls the function app.refreshTick, and t...

4 years ago | 0

Answered
How to write a sequential algorithm
I think the first element of A when i = 2 should be 2 instead of 3. If so, then: Columns=[1:36]; for i = 1:numel(Columns...

4 years ago | 0

Answered
The size of my final matrix is wrong in a nested loop
Is this what you want to do? A = [1 2 3 4 5 6 7 8]; for c = 1:1:size(A,1) row1 = A(c, 1); Final = []; ...

4 years ago | 0

| accepted

Answered
I want my function to return -1 when the file doesn't open.
Your code is explicitly throwing the error, here: error('error opening file %s\n',fname); You can remove that line (and the ne...

4 years ago | 1

| accepted

Answered
A function that replaces any negatives with zeros
function x = NoNegatives(x) x(x < 0) = 0; Note that this function changes x in-place, so the output is also x - no need for a ...

4 years ago | 0

| accepted

Answered
Can someone explain to me what to do for Flux_i, Flux_c and Flux_L? I do not understand.
I think your code is fine as it is (since it produces an accurate plot of the given data), but it looks like there are at least ...

4 years ago | 0

Answered
Ask on export file name
str = 'whatever'; file_name = ['Profil_',str]; % use string concatenation (notice the double-quotes) "C:\Users\danie\OneDri...

4 years ago | 1

| accepted

Answered
How to get the grid points that lies within the one side of a straight line
In this case, your approach with inpolygon is ok, in that the lines specified by ln, yh_lat, etc., go far beyond the points in l...

4 years ago | 0

| accepted

Answered
How to represent percentage values in Matlab App Designer
Consider the differences in the following commands: val = '7' sprintf('%.0f%%',val*100) sprintf('%.0f%%',str2double(val)*100)...

4 years ago | 0

Answered
Is there a way to update the legend as the for goes on?
You can create the entire string array str before the loop, and use the first i elements of str in the legend each time through ...

4 years ago | 0

Answered
Keeping the rows in an array with specified numbers
numbersTokeep = [5,6]; A = magic(5); disp(A); % keep rows where column 2 is 5 or 6: A = A(ismember(A(:,2),numbersTokeep),:);...

4 years ago | 0

| accepted

Answered
How do we define the colors in the MarkerFaceColor for the plots containing lines and points?
Inspect either of the properties shown here: get(0,'DefaultAxesColorOrder') % default line colors for any axes figure('Visible...

4 years ago | 0

| accepted

Answered
fprintf two column vectors at once
v1 = randn(10,1); % column vector, size 10-by-1 v2 = randn(10,1); % different options: [v1 v2] disp([v1 v2]); fprintf('%6...

4 years ago | 0

| accepted

Answered
Store function results from for loop
matrix = []; for do_shaft = .04:.001:.14 for h = .01:.001:.10 for w = .01:.001:.10 Nf = func(inputs...

4 years ago | 0

Answered
How do I change the colors of my data points in a scatter plot?
Here is a link to the documentation explaining what the options and syntax are for changing line properties (including color) in...

4 years ago | 1

| accepted

Answered
How can I query whether a cell is full?
Based on the comments it sounds like you need to use size to check whether the given row and column indices are valid for the gi...

4 years ago | 0

Answered
creating for and while loop for an array data
I believe this has the behavior you are after. I'm not sure what should happen when you get to the end of array_data, i.e., may...

4 years ago | 1

| accepted

Answered
How can I display the relevant pictures in Fig2 in real time after right-clicking to get the coordinate information from Fig1?
Merely issuing this command: Fig2 does not make Fig2 the current figure, which I think is your intent. Instead, you can say: ...

4 years ago | 1

| accepted

Answered
Shade area between two curves
My best guess for what's happening (since I don't have your variables and I don't have Simulink) is that the variables are colum...

4 years ago | 0

| accepted

Answered
I want t write a number to a file
It seems to work ok here: fOutput = fopen('test.txt','wt'); fprintf(fOutput,'%5.2d',22.56); fclose(fOutput); ls *.txt typ...

4 years ago | 0

| accepted

Answered
Can I comment only a section or part of a line?
I think the best you can do is this: plot(x1,y1, ...{comment only inside brackets}, x2,y2);

4 years ago | 0

Answered
Error with readtable function
I'm not sure what the error with readtable is about, but here's one way to read that text file (I've given it the extension .txt...

4 years ago | 1

Answered
How to delete the words/characters from a .txt file?
Here's one way to get just the numbers out, which you can then do whatever you want with, including writing to a csv file (using...

4 years ago | 0

| accepted

Answered
how to plot contour function
x = 0:10; y = 0:0.2:2; [X,Y] = meshgrid(x,y); T = X.*exp(Y); contour(X,Y,T) % using matrices X, Y % contour(x,y,T) % same r...

4 years ago | 0

| accepted

Answered
How to create a matrix using Booleans that looks like this:
A = ones(5); % initialize A as a 5-by-5 matrix of all ones for ii = 1:size(A,1) A(ii,1:ii-1) = 4+ii; % fill in each row up...

4 years ago | 0

Answered
I need help implementing Challenges into my code. Please help!
For Challenge #1, don't put quotes around a because a is a variable storing the value of the MarkerFaceColor you want to use ('g...

4 years ago | 0

Answered
Plotting multiple linear models on one plot
You can store the line handles returned from plot(), and change the colors after the lines are plotted. mdl1 = fitlm(rand(5,1),...

4 years ago | 0

| accepted

Answered
How to code a generic for loop that removes a row with missing requirement
A = magic(50); row = size(A,1); n = 3; %or whatever number rows_to_delete = []; for r = 1:1:row if ~ismember(n, A(r...

4 years ago | 0

| accepted

Load more