Answered
How can I solve this problem?
This will capture any errors that happen in that if block, display the error message to the command line, and continue with the ...

4 years ago | 0

| accepted

Answered
I want to simulate a sine waveform with voltage sag in MATLAB (mfile). How can I do this?
t=0:0.0001:0.3; f=50; Vm=1.4; Vsag=0.2; V = Vm*sin(2*pi*f*t); idx = t > 0.1 & t < 0.2; V(idx) = V(idx)*Vsag/Vm; plo...

4 years ago | 1

| accepted

Answered
How can I set max & min value but maintain the curve trend?
clear all clc clf close all load('wavelength.mat'); filename = ('PDA36A_spectrum2_sam.xlsx'); data = xlsread(filename);...

4 years ago | 0

Answered
How to add specific rows to a matrix?
A =[ 3.8 6.4 2.0 3.8 6.4 5.0 3.8 6.4 9.0 3.8 6.5 4.0 3.8 6.5 3.0 3.9...

4 years ago | 1

| accepted

Answered
Problem 44948. Calculate a Damped Sinusoid - I get the correct answers when I "Run" but fail the Tests when I "Submit"
I think it's because you still have this in there: y_test = lambda + T + N; and that's what is being returned from your ...

4 years ago | 0

| accepted

Answered
How to add independent legends to each plot
If you keep track of your line handles and their associated names for the legend, then it won't be too much trouble when you com...

4 years ago | 0

Answered
How to pass extra parameters to custom Output Function?
Regardless of whether you define a function handle that uses testFCN or you call testFCN directly, make sure your testFCN is def...

4 years ago | 0

| accepted

Answered
Mean function returning super low ( and wrong) value for a specific variable
-1.9275e-17 is pretty close to 0, so that seems plausible to me, given a. Using the values as displayed, with 4 decimal points ...

4 years ago | 0

Answered
How to change size and color of only some edges of a patch?
There are a couple of options for the 'EdgeColor' of a patch object that may work, e.g., use 'EdgeColor' 'flat' to have each edg...

4 years ago | 1

| accepted

Answered
How can I create a logarithmic decrement line of best fit on a signal?
Something along these lines may work (or I'm sure there are slightly easier alternatives using the Curve Fitting Toolbox): % ti...

4 years ago | 0

| accepted

Answered
How can I call variables numbers from a table using individual variable row and column
M = readmatrix('input.csv') Or, if your version of MATLAB is a little older: M = csvread('input.csv') Then the cells in the t...

4 years ago | 1

| accepted

Answered
関数のグラフにおいて、最大値を求める方法を教えてください。
x = 0:100; y = 0:0.01:0.5; A = 1; B = 1; C = 1; D = 1; E = 1; F = 1; H = 1; [x,y] = meshgrid(x,y); z = A*x.*y.^3 + B*y.^...

4 years ago | 1

Answered
combining elements in array
A= [1 1 1 0 1 1 0 0 ]; M = 2; % number of elements of A to group together in sets N = numel(A); d = reshape(A(1:N-rem(N,M...

4 years ago | 0

| accepted

Answered
I dont want two bar graphs too overlap eachother.
You could shift one set of bars a little to the left and one to the right and also specify the bar width, to get something like ...

4 years ago | 0

Answered
Assign Character based on condition
if ii == 3 X_5 (:,1) = X_5 (:,1)*(2); elseif ii == 2 Y_5 (:,1) = Y_5 (:,1)*(2); end

4 years ago | 0

| accepted

Answered
Averaging multiple structures of different lengths
This will combine a.StepLengthSym and b.StepLengthSym into a single column vector c that you can then take the average of: c = ...

4 years ago | 0

| accepted

Answered
How can I assign different colors in my plot?
% some random GR data: depth = linspace(3150,3400,500).'; GR = 20*randn(500,1)+120; % and some layer boundaries: tops = [320...

4 years ago | 0

Answered
I am trying to mask values in a matrix that are out of a specified range and trying to make a new matrix from the values after the values out of the range have been masked.
It's not entirely clear exactly what you have in mind, but one or more of these options should cover it. If not, please explain ...

4 years ago | 0

| accepted

Answered
How can I choose non-repeating values with a probability of 90% and 10% ?
To generate a number that has value 1 with 90% probability and value 0 with 10% probability, you can use randi() to generate a r...

4 years ago | 0

| accepted

Answered
Is there a way to execute two for-loops at once?
You can use a single for-loop: SetNo=[1 3 9 9 9 10 10 10 45 46 49 49 49 50 50 50 51 51 51 52 52 52 53 54 57 58 59 60]; PhaseNo...

4 years ago | 1

| accepted

Answered
Semilog in 3d scatter graph
You can do set(gca(),'XScale','log') after you create your scatter plot: % Using random data figure (1) scatter3(rand(1,100),...

4 years ago | 0

Answered
Stubborn annotation? Cannot be found by a search? Even though it exists...
The reason findobj() doesn't work is because SampledColor's parent AnnotationPane has its 'HandleVisibility' set to 'off': Figu...

4 years ago | 0

Answered
setappdata, where to verify?
Use getappdata(FigureH) to view/verify the application data associated with FigureH via setappdata().

4 years ago | 0

| accepted

Answered
How to print outputs in different lines and save them in a file?
Use 'a' rather than 'w' in fopen(): fileID = fopen('exp.txt2','a'); to open a file for appending, without discarding the exist...

4 years ago | 2

| accepted

Answered
How can I create a patch between two graphs?
clear all;clc; s = [1 2 3 4]; t = [2 3 4 5]; x = [0 1 2 2 4]; y = [0 0 0 0 0]; z = [1 1 2 3 3]; G = graph(s,t); G.Nodes.X...

4 years ago | 0

| accepted

Answered
write equation in for loop
If you want to overwrite the values of a, x, y, and P on each iteration, then maybe you can do this: P = P-a*(x-y); If instead...

4 years ago | 1

| accepted

Answered
How to plot a graph with a set of updated values from the for loop?
It might be something like this: ii = 1; x = 1; y = 1; while ii < 10 x(ii+1) = x(ii)+1; y(ii+1) = y(ii)*2; ii...

4 years ago | 0

Answered
How to output individual digits from a user input of 2 digit numbers?
A while loop would be useful if you need to handle numbers with any number of digits, but since you're only doing 2-digit number...

4 years ago | 1

| accepted

Answered
How can I import a column of numbers in a text file into a Matrix
Use load() or readmatrix() to read the file, then indexing to separate it into three matrices: % replace file.txt with your...

4 years ago | 0

Answered
fprintf Command Script Calling
x = randn(1,3); for i = 1:5 fprintf('%d |%8.2f|%16.8f| % 20.16e| \n', i, x); end

4 years ago | 0

Load more