https://au.mathworks.com/matlabcentral/answers/questionsMATLAB Answers — New Questions2019-12-06T15:29:13Ztag:au.mathworks.com,2005:Question/4952472019-12-06T15:05:43Z2019-12-06T15:29:13ZFinding the Sum of a Finite SeriesHello,
I am trying to calculate the sum of a series (x*y)^i which takes as inputs values n, x, y. I am trying to use a while loop, however, I keep getting stuck. Any ideas how to proceed?
Thank you Agnieszka Polakhttps://au.mathworks.com/matlabcentral/profile/authors/13773993-agnieszka-polaktag:au.mathworks.com,2005:Question/4952512019-12-06T15:28:16Z2019-12-06T15:28:16ZFit Powerlaw to DataHi all!
I need to fit following Power Law to some experimental data.
y = C(B+x)^n
The data i have is as the following:
STRESS = [0.574, 367.364, 449.112, 531.087, 649.097, 695.038, 737.173, 815.008];
STRAIN = [2.8746e-04, 0.00063, 0.0459, 0.0901, 0.1320, 0.1725, 0.2132, 0.2557, 0.3579];
I would like estimates for C, B and n.
Im not sure how to use the fitting tool for this kind of specific model.
Any ideas or suggestions would be greatly appreciated!
Thank you very much!
Tobias Brammingehttps://au.mathworks.com/matlabcentral/profile/authors/6162721-tobias-brammingetag:au.mathworks.com,2005:Question/4949202019-12-05T00:51:12Z2019-12-06T15:26:34Zplot with input argumentsi want to subplot 4 string containg cell array from ( sin, cos, tan,sinh) and vector (+,o,*,x,s) and the mathmatical function should be ploted in interval (-2pi,2pi)with step 0.3Roger Nadalhttps://au.mathworks.com/matlabcentral/profile/authors/16935264-roger-nadaltag:au.mathworks.com,2005:Question/4952332019-12-06T13:46:30Z2019-12-06T15:26:25ZThingspeak, Analysing within a channelHi Team,
I have a channel with data in field1 to field6. Now I want to use these data points to calculate the values for field 7. But I can't write the data with the exact same timestamp as the values of field1 to field6. I know, I could write the calculated data into a new channel, but I think this is a rather inelegant solution. One workaround is to add one second to the timestamps. But again, I would prefer a cleaner solution. Is there a way to do this properly?Julius Küblerhttps://au.mathworks.com/matlabcentral/profile/authors/5252645-julius-kublertag:au.mathworks.com,2005:Question/4952502019-12-06T15:26:22Z2019-12-06T15:26:22ZFind roots of a poly without using embedded functionsIve been trying to find different methods to find the roots of a polynomial with user entered coefficents but ive gotten no where. Any idea how i could use a loop in order to set the value of a symbolic variable to a different value, in order to find the root of said equation. Thank youDaniel Morrishttps://au.mathworks.com/matlabcentral/profile/authors/16826838-daniel-morristag:au.mathworks.com,2005:Question/4942522019-12-02T05:41:57Z2019-12-06T15:22:33ZHow to read data in more than 2 fields in thingspeak?Hi Team
I have this following URL and want to read data to it, i want to read 2 fields within the URL itself. How can i read 2 or 3 fields to it using below URL? Documentation does not have this including, only 1 fields per each request. Please assist, thanks.
https://api.thingspeak.com/channels/899906/fields/last_data_age.csv?api_key=F35GLOFJ8L99D0OM
Gcobani Mkontwanahttps://au.mathworks.com/matlabcentral/profile/authors/16732836-gcobani-mkontwanatag:au.mathworks.com,2005:Question/4951612019-12-06T04:23:06Z2019-12-06T15:21:57ZHelp with creating a different type of pareto chart?Hello,
I am wanting to create a pareto chart, but the standard chart that matlab creates is not exactly what I am looking for. I am looking to have a pareto chart that displays on the x-axis a histogram of the distribution, but then just simply displays the summed pareto line counting the percentage of data from left to right.
I can create an example of what I mean in excel using pivot tables, and manually creating a combo chart.
Assume the data I have is:
Y=[ 81 15 21 38 38 21 31 27 22 135 55 24 54 66 97 11 117 332 140 34 456 484 39 12 63 58 52 100 43 16 31 163 173 182 80 216 64 24 27 57 13 589 57 23 31 40 19 37 57 10 57 31 97 95 102 14 178 202 130 12 14 41 37 91 199]
If I run in Matlab pareto(Y), the image I get is the following:
However, this is not exactly what I want. I can show an example of how I'd like it to look using excel. You can see here, the first column is the same data from the variable above Y, however it is only the UNIQUE values. The second column is the count of each occurrence(distribution). The third column is the running total of the count as a percentage of the grand total of items in Y.
The graph plotted is simply a combo chart, with a distribution of the first two columns, and the pareto line is simply the running total plotted on the right side secondary axis. The image of that is here:
SO is there any easy way to accomplish this? I would like to keep the chart in ascending order in the way the excel image I have is.
Also, is there a way to bin this up if necessary, I.e., if I wanted to group values together to have a wider bin size?Forresthttps://au.mathworks.com/matlabcentral/profile/authors/2353650-forresttag:au.mathworks.com,2005:Question/4939222019-11-29T16:51:40Z2019-12-06T15:20:55ZFind the help for sim command in the MPC ToolboxThe sim command can be used to simulate Simulink models or MPC objects. How can I open the Help Browser from the command line for the sim in the MPC Toolbox? The "doc sim" command open the reference for Simulink sim, not MPC sim.
I could use the "doc mpc/sim" command in the past to get help from the command line for the MPC sim. It doesn't seem to work in R2018b.J Chenhttps://au.mathworks.com/matlabcentral/profile/authors/14120848-j-chentag:au.mathworks.com,2005:Question/4952492019-12-06T15:20:42Z2019-12-06T15:20:42Zfind main area of imageHello,
I am trying to lear how I can remove the small objects to find the main area of the image (the black section between the long lines (edges)? I want ot get rid of external and internal objects.
Thanks for the helps
Very Determinedhttps://au.mathworks.com/matlabcentral/profile/authors/7366145-very-determinedtag:au.mathworks.com,2005:Question/4951942019-12-06T09:17:28Z2019-12-06T15:20:20ZSimulink compare shows false positivesHello
I'm using Matlab 2017b compare tool to review changes in simulink libraries.
I see false-positive differences quite often. Simulink Compare, for some reason, tries to compare 'Compare to constant1' to 'Compare to constant3'.
There are compare to constant 1...3 blocks, none of them changed. They have the same source signal, the same output signal, something else changed in the model.
What could be the cause for these? Is this a known bug, is there a fix?Gergely Bencsikhttps://au.mathworks.com/matlabcentral/profile/authors/8238509-gergely-bencsiktag:au.mathworks.com,2005:Question/4950502019-12-05T16:09:05Z2019-12-06T15:20:03Zdiff equation solved by ode45 hi,
in my final project i need to solve an diff equation which represent a physical model
my quation is if ode45 is capable of solveing this problem, our i need to use other matod.
all capital letters are constant numbers.
the equition is in the picture attached.
thanks.anton deynekahttps://au.mathworks.com/matlabcentral/profile/authors/10672781-anton-deynekatag:au.mathworks.com,2005:Question/4951472019-12-06T02:18:21Z2019-12-06T15:17:52ZThingSpeak Channel Does Not Update Automatically when using ESP8266 with AT Commands and C Programming LanguageI am very new to this area. My small project is as follows:
MCU: NXP
ESP8266 module
C programming language with AT Commands for ESP8266
IDE: Online Mbed Complier
ThingSpeak Cloud Server
My goal is simply to simply read data (measurement) from a sensor and push it to ThingSpeak cloud. Part of my code with AT commands for ESP8266 module is as follows:
//Sending Data to the Cloud Server via ESP8266 WiFi Module
strcpy(snd,"AT+CIPMUX=0\n\r"); //AT+CIPMUX: Enabling Single Channel Mode
wifi.SendCMD(snd);
wait(1);
wifi.RcvReply(rcv, 1000);
wait(1);
sprintf(snd,"AT+CIPSTART=4,\"TCP\",\"%s\",80\n",CloudIP); //Establish TCP connection w/ Cloud Server
wait(1);
wifi.RcvReply(rcv, 1000);
wait(1);
strcpy(snd,"AT+CIPSEND=100\n\r"); //Set length of the data that will be sent
wifi.SendCMD(snd);
pc.printf("%s\r", rcv);
wait(1);
wifi.RcvReply(rcv, 1000);
pc.printf("%s\r", rcv);
wait(1);
//Pushing the data acquired from HC-SR04 Ultrasonic Sensor to Cloud Server via API
sprintf(snd,"GET https://api.thingspeak.com/update?api_key=3LV9GHWHJYDZNWEH&field1=%f \r\n\r\n", dist_percent);
pc.printf("%s\r",snd);
wifi.SendCMD(snd);
wait(1);
wifi.RcvReply(rcv, 1000);
pc.printf("%s\r", rcv);
Before this, I do initialization part for connecting my ESP module to my Wifi router. That works fine. No issues.
Problem: I need to click on the GET link as shown in the screenshot below, in order to update my ThingSpeak cloud server. I have tried many AT commands but none seems to automatically update cloud. Everytime, I have to open terminal (TeraTerm) and then double click on the link, which then opens a new web page with just a single digit. Then after I go back to my ThingSpeak Channel dashboard, I see the new value. Else, channel does not automatically update itself. Please note that I am only updating (writing the channel), not reading from it or anything.
(Screenshot with the GET link. When I double click on it, only then does my ThingSpeak Channel gets updated).
Is there a way to automate this? Am I missing any AT command or anything else? I apologize, I am new to programming ESP module and ThingSpeak server. So, your help will be much appreciated. Thank you for your time.Jakob Jacksonhttps://au.mathworks.com/matlabcentral/profile/authors/17034762-jakob-jacksontag:au.mathworks.com,2005:Question/4952432019-12-06T14:39:49Z2019-12-06T15:16:03ZHow do I extract all rows of a struct field that is a character array?I want to extract all rows of a field within a struct. The field is a character array.
For sake of example, the struct is called systemData, with a field called Objects, which has a field called status (among many others). The status field is a char, and has 20 rows.
I'd like to extract all 20 rows of systemData.systemObjects.status
When I try "normal" index operations, I either only get one result, or I get an error.
Here is one attempt, which results in an error:
systemData.Objects.status{:}
Error: Expected one output from a curly brace or dot indexing expression, but there were 20 results.
I also tried this:
test_extract = systemData.Objects.status;
But I only get the first row.
How do I extract all rows?Pat Cannyhttps://au.mathworks.com/matlabcentral/profile/authors/11948165-pat-cannytag:au.mathworks.com,2005:Question/4952412019-12-06T14:31:30Z2019-12-06T15:15:09ZUse vector elemnts one byone in while loop to do calculationsI'm facing problem when I'm trying to use loop which goes values 2 to10 trough so that first 2 is calculated inside while loop and the counter value n for that should be 1 and then use 3 to do the same and so on until the for loop is ended with value of 10. The purpose is to save n value of each element for example i=3 to vector l. I mean if i is 2 then the n for that element is 1 and if 3 then the n value for that elemnt in vector l should be 3 and so on. Problem is that the values are incorrect in vector l as i=3 is now 4 and i=4 is 6.
.
clc
clear all
n=0; % setting up the counter
l=[];
t=[]
for i=2:10
t=[t i]
while i>1
if mod(i,2)==0;
i=i/2;
n=n+1
else
i=i+1;
n=n+1
end
end
l=[l n]
end
torrehttps://au.mathworks.com/matlabcentral/profile/authors/13433233-torretag:au.mathworks.com,2005:Question/4943062019-12-02T12:26:36Z2019-12-06T15:14:23ZCompare Betas from two different GLMSHi
I am trying to compare the betas from two different glms. For each model I have the following output: (This is the output for only 1 model).
I want to compare the fixed effects coefficients from Model 1 with those from Model 2, i.e. "Is Evidence_Control_11 (Model1) significantly different from Evidence_Control_11 (Model2)? The models differ with regards to the number of observations. However, the formula is equivalent for both models.
I would be grateful for guidance.
Thanks!
Peter Phttps://au.mathworks.com/matlabcentral/profile/authors/16312291-peter-ptag:au.mathworks.com,2005:Question/4951952019-12-06T09:17:43Z2019-12-06T15:13:33ZI want to show the Magnitude response of three filters, as one responseSo, I am to design three butter filters, a low pass, band pass, and a high pass, with the biggest wrinkle being that they must each have a different order (other wise, I'd just create a band stop filter with two stops). (Technically 7, 8, and 10, but I'll get to that later.) I have no problem with that, but I want to get the freq response as a single line that shows what happens when all three filters are inline with one another. (Right now I can just show how each one campares, which is mostly useless, from my perspective. Below is where I am so far. Thank you for the help.
clear;
freqSample = 10000;
freqCutoffLow = 100;
bandPassLower = 500;
bandPassUpper = 1000;
freqCutoffHigh = 2000;
%as = [1/(freqCutoff*2*pi),1];
nLow = 8; % orderOfFilter;
nBandPass = 8;
nHighPass = 10;
wNLow= freqCutoffLow / (freqSample/2); %normalizedCutOffFreq
[lowA,lowB] = butter(nLow, wNLow);
[passA,passB] = butter(nBandPass,[bandPassLower bandPassUpper]/(freqSample/2));
[highA, highB] = butter(nHighPass, freqCutoffHigh/(freqSample/2),'high');
fvt = fvtool(lowA, lowB, passA, passB, highA, highB);
legend(fvt,'butterLow', 'butterHigh', 'butterPass')
Carl Eraniohttps://au.mathworks.com/matlabcentral/profile/authors/9030134-carl-eraniotag:au.mathworks.com,2005:Question/4951322019-12-06T00:42:22Z2019-12-06T15:12:17ZRemove periodic Noise and convert photo to RGB again Here i have an image with periodic noise and i want to convert it to frequency domain using Fourier transform and apply notch filter to remove noise and then inverese fourier transform to get image to spatial domain again and convert it to RGB image again. Here is my code for that but i just convert image to frequence domain and apply filter but doesn't work and after that inverese fourier transform to convert image to spatial domain but can't convert it to RGB and just saw image without colors.
f = im2double(rgb2gray(imread('Moire2.bmp')));
imshow(f), title('Original Image');
F = fft2(f);
%create filter for noise removal but doesn't work and need changes
H = ones(size(f));
x = 10;
H(165-x:169+x, 127-x:131+x) = 0;
H(170-x:174+x, 61-x:65+x) = 0;
H = ifftshift(H);
% apply your own filter to image
filtered = F .* H;
figure, imshow(filtered) , title('Filter');
% inverse fourier trensform to restore image to spatial Domain again and i want to convert it to RGB image but can't do that
f1 = ifft2(filtered);
figure, imshow(f1), title('Restored Image'); Ahmed Emadhttps://au.mathworks.com/matlabcentral/profile/authors/16264900-ahmed-emadtag:au.mathworks.com,2005:Question/4952482019-12-06T15:12:03Z2019-12-06T15:12:03ZNeed help on a SPECIFIC CASE of finding local extremeI wrote a code to find local extremes and tested it with a few functions. Things were going smoothly until this ONE CASE: f(x)=(x+1)^(2/3)-x. Matlab returns only one local extreme where there should have been two. I also included the ezplot function in my code to see how the graphs look but when Matlab sketch this function's graph it.....just CAN'T, it only graphs the funtion from -1 while the domain of the function itself is much larger.
Note: My code runs with other functions like discontinuos function: abs(x) and ofcourse smoothly with continous functions.
disp('This is MaxImin');
syms x ;
disp(' please input f');
f = input('f(x)=');
g = diff(f);
h = diff(g)
CP = solve(diff(f),x)
s = numel(CP)
for i=1:s
if subs(h,CP(i))>0
disp('Local minima is achieved')
Min=[CP(i);subs(f,CP(i))]
elseif subs(h,CP(i))<0
disp('Local Maxima is achieved')
Max=[CP(i);subs(f,CP(i))]
end
end
ezplot(f);
hold on;
plot(CP,subs(f,CP(i)),'r o');
grid on;Jacked Danielhttps://au.mathworks.com/matlabcentral/profile/authors/16948000-jacked-danieltag:au.mathworks.com,2005:Question/4952272019-12-06T12:42:09Z2019-12-06T15:10:41Zhow to space overlapping labels in plotDear all,
I´m analyzing MRI data and need to plot the intensity values and behavioural scores of a single voxel from a sample of patients. To label the data points, I used the identifier for each patient.
However, even if I decrease the font size for the labels, they overlap for those data points in close spatial proximity. I have tried to get around this by modifying the plot box and data aspect ratio but haven´t solved the problem yet.
I´d really appreciate if someone in the forum could help me with this since I´m sure it will be a recurrent issue in the future.
Here´s the main code I used for the plot. You can find the plot attached.
x=Syl_FJ12_PERC_MODEL_TP1.beh_cov;
y=cell2mat(pa_int_fixed(:,2));
label=pa_int_fixed(:,1);
figure
plot(x,y, '.r','MarkerSize', 15)
text(x, y, label,'fontSize',8);
title ('VBM Sanity check'), ylabel('GM Intensity Peak Voxel (-36 15 -33) Temp_Pole_Mid_L'), xlabel ('Syl JK12 Perc Model')
Thanks in advance for your time,
NoeliaNoelia Martínezhttps://au.mathworks.com/matlabcentral/profile/authors/4334754-noelia-martineztag:au.mathworks.com,2005:Question/4951212019-12-05T23:03:14Z2019-12-06T15:10:41Zhow i can separate the different mix up voices in matlab i have no code
i have only the audio in which five or six people taking to each other and i want to separate the voice and listen it one by one
Muhammad murtazahttps://au.mathworks.com/matlabcentral/profile/authors/13931295-muhammad-murtazatag:au.mathworks.com,2005:Question/4951662019-12-06T04:51:57Z2019-12-06T15:07:15ZDon't know why SLDV checks compatibility failDear bros,
My model update (Ctrl + D) and run (Ctrl +T) was OK. But when i used SLDV to check compatibilty, SLDV report failed as following figure
But diagnostics window had no information about error.
Do any one know how to find error in model
galaxyhttps://au.mathworks.com/matlabcentral/profile/authors/15063927-galaxytag:au.mathworks.com,2005:Question/4951292019-12-06T00:26:35Z2019-12-06T15:07:12ZTrying to have user input names into matlab and store them in a matrixI am working on a project where I can input names and have them stored in a matrix or vector, but keep getting this error.
"Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
Error in Cy_Young_Program (line 4)
pitcher_prompt(pn) = input('Input Pitcher Name: ',"s")"
Here is the code I am using...
injury_prob = rand;
%Code for inputing different pitchers names
for pn = 1:3
pitcher_prompt(pn) = input('Input Pitcher Name: ',"s")
%ppm()
end
Christian Resslerhttps://au.mathworks.com/matlabcentral/profile/authors/16048463-christian-resslertag:au.mathworks.com,2005:Question/4604132019-05-06T00:38:04Z2019-12-06T15:06:00ZAppDesigner questions: 1) Image path 2) numerical value outputI'm BRAND NEW to MATLAB and I have a project due in just a few hours. There are a couple of things that I have been stuck with for a few days now.
1) Every time I try to add an image, in AppDesigner, it let's me place the box, but then when I hit browse it give me an error message: "Before specifying the imagesource file, add it to the MATLAB path. I have the image in the samefile that the app I'm working on is in. I have also tried to move it around to viturally every place that MATLAB is on my computer with no luck. Any help.
2) How can I make a result from a function be a numerical output rather than a say a graph?
ThanksRexx Thomashttps://au.mathworks.com/matlabcentral/profile/authors/15219561-rexx-thomastag:au.mathworks.com,2005:Question/4952442019-12-06T14:48:48Z2019-12-06T15:04:21ZMost efficient way to enter values into pre-allocated sparse matrix?I have a problem where I have a sparse matrix of a specific size, 4000 x 4000. The problem also has a tri-diagonal structure such that I know which elements of the sparse matrix will be non-zero. It is blocks of 4 x 4 along the main diagonal, and the first of-diagonals.
My issue is that I have to compute the 4 x 4 block iteratively, and store them in the matrix as I compute them.
A = spalloc(4000,4000,4*4*1000*3); % Sparse matrix allocation
for i = 1:1000
idx = (1:8)+4(i-1); % In each iteration, the indices that change are known
A(idx,idx) = A(idx,idx) + Ri; % The matrix Ri depends on i
end
Exactly how the matrix that is added, Ri, depend on the interation is a bit complicated to explain. It depends on an outside process, but it has the following structure
% Either
Ri = [A B; B.' C];
% or
Ri = [D E; E.' F];
Which one it is in each iteration depends on a random process that is (and has to be) randomly sampled in each iteration.
From what I have read about sparse matrices in Matlab, it appears to be important how sparse matrices are constructed, where a bad way may take much longer than a better way. So, does anyone known the best way to do this?Tudorhttps://au.mathworks.com/matlabcentral/profile/authors/8311978-tudortag:au.mathworks.com,2005:Question/4952462019-12-06T15:04:02Z2019-12-06T15:04:02ZMATLAB 2019b, How to make variables open as a separate window as in the previous versions? In the previous verions of MATLAB, when you open variable in a window, the next variable would open in a separate window. How to change that? Thanks. Rammhttps://au.mathworks.com/matlabcentral/profile/authors/10963037-rammtag:au.mathworks.com,2005:Question/4951222019-12-05T23:05:22Z2019-12-06T14:57:04ZSimulink Project Opens Multiple Copies when Simulink Design Verifier is RunI created a simulink project with multiple models, main high level model, plant model and control model. It works fine. I added simulink design verifier to my project to verify some prepreties in the control model (SLDV is run on the control model only). I run simulink design verifier in property proving mode not in test generation. It generated the report. Then, whenever I open the project it opens many copies of the main model. I cleard the simulink cache folder and SLDV output folder but the problem still there. What am I missing here? I assume that SLDV creates multiple test scenarios to falsify the requirements but why they are called everytime I open the project even without calling the test harness?
ahmed Ghareebhttps://au.mathworks.com/matlabcentral/profile/authors/3493842-ahmed-ghareebtag:au.mathworks.com,2005:Question/4952452019-12-06T14:54:30Z2019-12-06T14:54:30ZWriting Cell Attributes to HDF5 FileIn Matlab R2018a, I can write HDF5 attributes with a cell input. Following the Matlab example for using hdf5write:
attr = {'Time' 'Var1' 'Var2'};
attr_details.Name = 'ColumnHeaders';
attr_details.AttachedTo = '/group';
attr_details.AttachType = 'dataset';
dset = rand(10,3);
dset_details.Location = '/';
dset_details.Name = 'group';
hdf5write('myfile.h5', dset_details, dset, attr_details, attr);
I noticed that Matlab is now warning that hdf5write will be removed, and says to use h5write instead. However, I can't seem to write attributes with a cell array. When I try to use h5writeatt with the attr variable above, I get an error that says "'cell' is not supported as an attribute datatype."
h5create('myfile.h5', '/group', size(dset));
h5write('myfile.h5', '/group', dset);
h5writeatt('myfile.h5', '/group', 'ColumnHeaders', attr);
% h5writeatt('myfile.h5', '/group', 'ColumnHeaders', attr, 'TextEncoding', 'system'); % give same error
Is there a workaround to this, or will it be an added feature whenever hdf5write is removed?M Rhttps://au.mathworks.com/matlabcentral/profile/authors/8281282-m-rtag:au.mathworks.com,2005:Question/4951102019-12-05T21:00:53Z2019-12-06T14:52:32ZHow to reduce For loop execution time?I have following Matlab code to calculate summation of exponential summation term:
This code takes approx. 600 seconds to give final output s. Is there any way to reduce this computation time?
sum1 = 0;
s = 0;
for i=1:1000000000
for j=1:3
sum1 = sum1+(i*proc(j))^2;
end
s = s+exp(-sum1);
endAjinkya Bankarhttps://au.mathworks.com/matlabcentral/profile/authors/15571509-ajinkya-bankartag:au.mathworks.com,2005:Question/4946502019-12-03T19:33:31Z2019-12-06T14:46:57ZCut timetable data following certain conditionsI have created a timetable that has one minute timesteps. I would like to take this timetable and create most likely a cell object of chunks of the data following these conditions listed below. If there is a better way to get this data, I'd love to hear suggestions. Thanks!
Criteria:
-to keep data
At least 5 min of continuous data (so positive, non-zero values)
Maximum of 5 minutes of no non-zero values between times whne data is present.
-to break up data into chunks.
No data for at least 60 minutes.
So, if there are five or more records with data, it should be taken and saved until the continuous records stop or, less than 6 values of no data between records occur. Then, after finding all these groups of data, I'd like to separate the groups with 60 minutes or more of no data between them.
Here's some sample data (timetable format):
'06-Feb-2019 03:40:00' 0 0
'06-Feb-2019 03:41:00' 0 0
'06-Feb-2019 03:42:00' 0 0
'06-Feb-2019 03:43:00' 0 0
'06-Feb-2019 03:44:00' 0 0
'06-Feb-2019 03:45:00' 0 0
'06-Feb-2019 03:46:00' 0 0
'06-Feb-2019 03:47:00' 0 0
'06-Feb-2019 03:48:00' 0 0
'06-Feb-2019 03:49:00' 0 0
'06-Feb-2019 03:50:00' 0.000900000000000000 0.00266666666666667
'06-Feb-2019 03:51:00' 0.00218333333333333 0.0195000000000000
'06-Feb-2019 03:52:00' 0 0
'06-Feb-2019 03:53:00' 0.00213333333333333 0.0118333333333333
'06-Feb-2019 03:54:00' 0.00286666666666667 0.0161666666666667
'06-Feb-2019 03:55:00' 0.00311666666666667 0.0213333333333333
'06-Feb-2019 03:56:00' 0.00161666666666667 0.00833333333333333
'06-Feb-2019 03:57:00' 0.00313333333333333 0.0173333333333333
'06-Feb-2019 03:58:00' 0.000633333333333333 0.00200000000000000
'06-Feb-2019 03:59:00' 0.00451666666666667 0.0521666666666667
'06-Feb-2019 04:00:00' 0 0
'06-Feb-2019 04:01:00' 0.000616666666666667 0.00183333333333333
'06-Feb-2019 04:02:00' 0 0
'06-Feb-2019 04:03:00' 0.000466666666666667 0.00133333333333333
'06-Feb-2019 04:04:00' 0.000500000000000000 0.00116666666666667
'06-Feb-2019 04:05:00' 0.00281666666666667 0.0141666666666667
'06-Feb-2019 04:06:00' 0.00376666666666667 0.0195000000000000
'06-Feb-2019 04:07:00' 0.00371666666666667 0.0150000000000000
'06-Feb-2019 04:08:00' 0.00235000000000000 0.00800000000000000
'06-Feb-2019 04:09:00' 0.00370000000000000 0.0151666666666667
'06-Feb-2019 04:10:00' 0.00341666666666667 0.0245000000000000
'06-Feb-2019 04:11:00' 0.00320000000000000 0.0170000000000000
'06-Feb-2019 04:12:00' 0.00410000000000000 0.0181666666666667
'06-Feb-2019 04:13:00' 0.00535000000000000 0.0396666666666667
'06-Feb-2019 04:14:00' 0.0116666666666667 0.0598333333333333
'06-Feb-2019 04:15:00' 0.00908333333333333 0.0375000000000000
'06-Feb-2019 04:16:00' 0.00708333333333333 0.0265000000000000
'06-Feb-2019 04:17:00' 0.00408333333333333 0.0126666666666667
'06-Feb-2019 04:18:00' 0.00598333333333333 0.0451666666666667
'06-Feb-2019 04:19:00' 0.0410166666666667 0.397333333333333
'06-Feb-2019 04:20:00' 0.0596166666666667 0.680333333333333
'06-Feb-2019 04:21:00' 0.0482500000000000 0.554166666666667
'06-Feb-2019 04:22:00' 0.0347333333333333 0.447500000000000
'06-Feb-2019 04:23:00' 0.00551666666666667 0.0335000000000000
'06-Feb-2019 04:24:00' 0.00425000000000000 0.0196666666666667
'06-Feb-2019 04:25:00' 0.00553333333333333 0.0450000000000000
'06-Feb-2019 04:26:00' 0.00823333333333333 0.0691666666666667
'06-Feb-2019 04:27:00' 0.00661666666666667 0.0560000000000000
'06-Feb-2019 04:28:00' 0.00968333333333333 0.0676666666666667
'06-Feb-2019 04:29:00' 0.00733333333333333 0.0455000000000000
'06-Feb-2019 04:30:00' 0.00471666666666667 0.0340000000000000
'06-Feb-2019 04:31:00' 0.00295000000000000 0.0191666666666667
'06-Feb-2019 04:32:00' 0.00441666666666667 0.0326666666666667
'06-Feb-2019 04:33:00' 0.00618333333333333 0.0575000000000000
'06-Feb-2019 04:34:00' 0.00696666666666667 0.0793333333333333
'06-Feb-2019 04:35:00' 0 0
'06-Feb-2019 04:36:00' 0 0
'06-Feb-2019 04:37:00' 0.000966666666666667 0.00616666666666667
'06-Feb-2019 04:38:00' 0 0
'06-Feb-2019 04:39:00' 0 0
'06-Feb-2019 04:40:00' 0 0
The data above should all be grouped together becasue breaks from 3:50 to 4:37 are less than 5 minutes. Let's assume that between the first timestep and ending timestep there were 60 consecutive zero values. I should metion that in all cases if one Variable is = 0 the second one will as well.
Eric Escotohttps://au.mathworks.com/matlabcentral/profile/authors/7056746-eric-escototag:au.mathworks.com,2005:Question/4951122019-12-05T21:31:09Z2019-12-06T14:39:17Zindex variable based on time pointsi have a variable with 1400 images stored in it. I want to index this loop into 40 time points, (so there are 40 variables each containing 35 frames)
mri % 128 x 128 x 1400 uint16
I am trying to build a loop that for each instance in the loop (t = 40), 35 frames are stored into an output variable so essentially at the end I could have an output variable which is
output % 128 x 128 x 35 frames x 40 timepoints
%here is the rudimentary code that I am working from to build into a for loop
perf_0 = mri(:,:,1:35);
perf_1 = mri(:,:,36:70);
perf_2 = mri(:,:,71:105);
perf_3 = mri(:,:,106:140);
perf_4 = mri(:,:,141:175);
perf_5 = mri(:,:,176:210);
perf_6 = mri(:,:,211:245);
Raheema Al Karim Damanihttps://au.mathworks.com/matlabcentral/profile/authors/15751635-raheema-al-karim-damanitag:au.mathworks.com,2005:Question/4952092019-12-06T11:02:40Z2019-12-06T14:36:39Zhow to fix the error "Z must be a matrix, not a scalar or vector"?hi
i have a project which at the end i have to plot x-y-z plot in simulink and as there isn't any 3D block in simulink i used matlab function to do it
here is my matlab code whichim not sure about it
function s = fcn(x,y,z)
surf(x,y,z)
s=1;
end
and here is my simulink blocks
the blocks in body-inertia axis transfer block
and blocks in my z_dot block
but at the end i get "Z must be a matrix, not a scalar or vector"
how can i fix it and whyi dont get this error for x and y?fatemeh phttps://au.mathworks.com/matlabcentral/profile/authors/12562759-fatemeh-ptag:au.mathworks.com,2005:Question/4950742019-12-05T17:53:24Z2019-12-06T14:35:02ZHow can I simulate data from two different distribution using Copulas?Hi!
I have been trying to create a Monte Carlo simulation model based on two set of data. Data X seem to fit a gamma distribution and data Y seem to fit either gumbel or lognormal distribution (lets assume it is lognormal for the sake of it).
So I basically tried to follow the guide "Simulating dependent random variables using copulas" but I can't seem to make it work. Probably because I don't fully get the whole concept behind it, but I know it should work for what I want to get. Right now I just seem to generate random values from 0 to 1 but I need it to do this in correlation to my data.
This is my code:
n=1000;
X=xlsread('XXXXXX.xlsx');
Y=xlsread('YYYYYY.xlsx');
rho=corr(X,Y)
Z = mvnrnd([0 0],[1 rho;rho 1], n);
U = normcdf(Z);
Q = [gaminv(U(:,1),2,1) exp(U(:,2))];
So what is left is to insert my data to the simulation, and I also assume I would have to fit my data using the gamfit and lognfit function.
Puntohttps://au.mathworks.com/matlabcentral/profile/authors/9110714-puntotag:au.mathworks.com,2005:Question/4952312019-12-06T13:28:35Z2019-12-06T14:34:13ZPlease help me about visualstudio 2010It's a C language program that accept 10 normal nums from 1 to 99(able to accept same number many times)
such as 1 12 34 56 78 89 75 32 45 7
then, even numbers should be printed straightly, but odd numbers' sequence will be changed that the larger number comes left
case of above: 89 12 34 56 78 75 45 32 7 1
I made source code. But it can only accept 10 numbers, not print result!
I have to hand out it by tomorrow 6 p.m
I attached my work by text file.
Please take a look at it and find what's wrong.
Thx.
I searched microsoft question(debate) community, but i couldn't find it. So i upload this question here. So please don't close this question.(I write this because one of the manager of this site closed it once)
Youngwookhttps://au.mathworks.com/matlabcentral/profile/authors/15611738-youngwooktag:au.mathworks.com,2005:Question/4937272019-11-28T15:02:23Z2019-12-06T14:34:07ZHow to remove specific colour from "surf" plot?I am trying to generate a density plot overlayed on a background image.
For me it is interesting the points where the density is higher, so I want to remove the blue color, or make it transparent somehow.
This is how i generated this figure. I used "dscatter" function from Mathworks to generate density plot.
figure
img = imread('estimulo_neutro.jpg');
image('CData',img,'XData',[0 1080],'YData',[1900 0])
x = vector0(:,1);
y = vector0(:,2);
hold on
t = dscatter(x, y, 'plottype', 'surf');
colormap(jet)
Mariana Melohttps://au.mathworks.com/matlabcentral/profile/authors/16065533-mariana-melotag:au.mathworks.com,2005:Question/4952422019-12-06T14:31:44Z2019-12-06T14:32:48ZSaving files in App DesignerHi, I am trying to save my document and I want to save my Table variable as the name I wrote in my EditField
savein=uigetdir(Name of the location);
str=strcat(savein, {'/'}, app.EditField.Value);
newstr=char(str);
Table = strjoin(app.Clasification.Data)'
newName = input (app.EditField.Value,"s")
S.(newName) = Table
save([newstr '.mat'],'-struct','S')
And I get Invalid field Name: ' '
Please helpTajana Lusetichttps://au.mathworks.com/matlabcentral/profile/authors/16465701-tajana-lusetictag:au.mathworks.com,2005:Question/4950822019-12-05T18:23:38Z2019-12-06T14:32:16ZDelete entire rows based on one conditionHello,
I am a beginner in Matlab. I have a table that has 7 columns and 240 rows.
I need to delete entire rows based on the following condition:
1. if a value of column 7 is superior than 1000 and inferior than 100 => delete this row
I have attached an image of how the datset looks like. Please help!Khayroon Suleymanhttps://au.mathworks.com/matlabcentral/profile/authors/16944497-khayroon-suleymantag:au.mathworks.com,2005:Question/4949822019-12-05T09:37:26Z2019-12-06T14:29:46Ztransform 5 minutes timeseries to hourly timeseriesI have a timeseries built with about 5 minutes time intervals among each observation. I would like to transform it in a hourly timeseries.
How can I do this?Gaetano Pavonehttps://au.mathworks.com/matlabcentral/profile/authors/7331525-gaetano-pavonetag:au.mathworks.com,2005:Question/4952402019-12-06T14:29:30Z2019-12-06T14:29:30ZJDBC Connection to Oracle DBHi I have insalled the new Java driver and got the following error
'JDBC Driver Error: No suitable driver found for jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=NA2Dcxcc)(PORT=1451)) (CONNECT_DATA=(SERVICE_NAME= X89FXZZ)))'
Could you help provide steps how to resolve this? Looks like I need to reinstall older Java SRE. However everytime, I restarted machine. I will get the same error message againPete shererhttps://au.mathworks.com/matlabcentral/profile/authors/1076536-pete-sherertag:au.mathworks.com,2005:Question/4882002019-10-30T02:46:50Z2019-12-06T14:28:13ZBrake rotor simulation - Couldn't get resultsHello Everyone, i'm Naveen from Texas. I have a code that simulates dynamic brake rotor temperature. I know the end result and graph. But code doesnt give me the same result. I hope its my mistake and someone can help me out.
Basically, the code simulates a car Accelerating to 60mph at 0.5G and decelerating to 30mph at 1.6G and accelerates to 60mph and repeats to 150 to 300 sec. The temperature curve has to saturate like in the picture.
I have attached the code file and the desired result file.Naveen Devarajhttps://au.mathworks.com/matlabcentral/profile/authors/16717759-naveen-devarajtag:au.mathworks.com,2005:Question/4952262019-12-06T12:38:15Z2019-12-06T14:27:19ZHow to create random group from excel?I have 30 rows and 2 colomn in excel. And i wan to make a random group from minimum 2 group with 15 row for each group and maximum 15 group which i can see in command window. How can i go on?
Thankssiska prifiharnihttps://au.mathworks.com/matlabcentral/profile/authors/17038293-siska-prifiharnitag:au.mathworks.com,2005:Question/4952322019-12-06T13:46:10Z2019-12-06T14:25:08ZHow do I use splitapply when the applied function has non-scalar output?I am trying clean variables in a dataset, creating a new table variable, but splitapply does not seam to allow for nonscalar outputs of the function.
As a minimal working example, I have a table
myTable = table();
myTable.Gender = ["Male","Female","Male","Female"]';
myTable.Var1 = [1,2,3,4]';
And I am now trying to create a new table variable where the group mean is subtracted from "Var1" (yielding Var2 = [-1, -1, 1, 1])
When using splitapply(), I get the error
Error using splitapply (line 132)
The function '...' returned a non-scalar value when applied to the 1st group of data.
Is there a way to do this, also for function more involved than demeaning the input variables?
Thanks in advance,
Chrisclauperhttps://au.mathworks.com/matlabcentral/profile/authors/9542205-claupertag:au.mathworks.com,2005:Question/4952362019-12-06T14:08:56Z2019-12-06T14:21:27ZClip 3D suface with surfConsider plotting a parameterized surface where . I am using the surf command to plot .
This surface spans a certain region in the 3D cartesian coordinates system and I wish to clip the surface with respect to plane parrallel to the (xOy) plane (or (yOz) or (xOz) planes). This is equivalent to find the correct subset to achieve such clipping but this could be diffucult given any .
I am thinking to write an event function that plot the point of the surface in this point is in the given region but I didn't suceed.
Example: Consider the sphere , , where .
If I want to remove the part of the sphere where ( so the sphere has is cut : it has a disk hole at ). I can compute to plot this cut surface but I would like a pure matlab way for any general surface. I don't want to clip the axis using for instance because I may have other surfaces in the region that I want to plot also.
If I am using the fimplicit3 command, we can achieve this using the yrange setting, but what is I can't use this implicit function because my surface can be only given in a parameterized form ?
smiliahttps://au.mathworks.com/matlabcentral/profile/authors/4072762-smiliatag:au.mathworks.com,2005:Question/4938202019-11-29T04:41:10Z2019-12-06T14:19:35ZHow to use the flags to enable\disable L1 Cache of GPU on Windows?
I have read through GPU books that one can disable L1 cache at compile time adding the flag -Xptxas -dlcm=cg to nvcc for all memory operations using nvcc. Also,the L1 cache can also be explicitly enabled with the flag -Xptxas -dlcm = ca.
I do not know how to write these commands in command prompt on windows.
seham moawedhttps://au.mathworks.com/matlabcentral/profile/authors/16978817-seham-moawedtag:au.mathworks.com,2005:Question/4952292019-12-06T13:12:36Z2019-12-06T14:18:40Z"compressor" a "expenader" system objets in Audio Toolbox does not workingCalling "compressor" or "expander" funkcion always gives back some error message, e.g.:
Not enough input arguments. Error in compressor (line 18) N = length(x);
Not enough input arguments. Error in compressor (line 23) alphaA = exp(-log(9)/(Fs * attackTime));
Error using /. Matrix dimensions must agree. Error in compressor (line 23) alphaA = exp(-log(9)/(Fs * attackTime));
The system objects seem to be unusable.
Jozef Juharhttps://au.mathworks.com/matlabcentral/profile/authors/1573604-jozef-juhartag:au.mathworks.com,2005:Question/4952382019-12-06T14:16:51Z2019-12-06T14:16:51Zwhat's a externally defined MCOS class ?Hello all,
I am getting this error while runing a test on testManager 'You must remove the externally defined MCOS class before you can use the dictionary definition'. I don't know what are MCOS class, and how do I remove one ?
Best regards.
Loubna.loubna ibnou fairouzehttps://au.mathworks.com/matlabcentral/profile/authors/7940862-loubna-ibnou-fairouzetag:au.mathworks.com,2005:Question/4952342019-12-06T13:55:47Z2019-12-06T14:15:38ZMove to next selectionhi all, I am wanting matlab to move to the next multi choice question if the chosen answer is "No"
eg:
choice = menu("Do you want to see the opening times of this recycling centre?","Yes","No")
if choice == 1
new_data(selectedplaceindex,1:3)
elseif choice == 2
%THIS IS THE LINE i STRUGGLE WITH
end
choice2 = menu("Do you want to navigate there?","Yes","No")
if choice2 == 1
new_data(selectedplaceindex,4)
elseif choice2 == 2
menu("Thank you, keep recycling!")
end
this is the selection process I want however, after "choice" is chosen, if "choice == 2" i want matlab to forget that selection and move on. equally with choice ==1 but i think that works anyway.Matthew Perryhttps://au.mathworks.com/matlabcentral/profile/authors/15019803-matthew-perrytag:au.mathworks.com,2005:Question/3723182017-12-11T15:31:24Z2019-12-06T14:14:33ZHow to read data after a specific word from txt file?I just start learning matlab. Now I want to read data from a txt file. The txt looks like this
EvtTime 12:11:33.034.438
Raw 0.00 m65S2c6 0.85 S1 22.43 S2 22.09 S3 -72.46
TTime 41:00:00.000.000 m65S2c7 0.02 S1 22.78 S2 23.35 S3 -44.46
TEHi 0.00 m65S2c11 -0.01 S1 22.66 S2 23.18 S4T03 22.15
TotalTm 160.38 S1T01 20.05 S1T11 23.55 S5T12 -11.18 S6BV08 42.26
LiveTm 114.63 S1T02 20.73 S1T10 20.33 S5T10 -15.52 S6BV05 42.13
EvtTime 12:15:23.225.518 65S2c7 0.01 S1-5C24 111.06 S2 23.41 S3 24.21
TotalTm 173.38 S1T01 21.95 S2T10 22.67 S3T19 -60.22 S4BV04 35.83
LiveTm 154.32 S1T02 21.70 S2T11 21.68 S3T20 -54.67 S4BV05 35.92
I need the value of 'EvtTime', 'TotalTm' and 'LiveTm', and the value is the number next to the words. The values should be read in vector. It will be like TotalTm = [160.38 170.38], and the LiveTm = [114.63 154.32]. The EvtTime will be read as time to plot.
My code doesn't work well. Here is my code:
fid = fopen('data.txt','r');
while ~feof(fid)
st = fgetl(fid);
if ~isempty(findstr(st,'TotalTm'))
ftell(fid);
fseek(fid,-9,0);
F = cell2mat(textscan(fid,'%5d'))
end
st = fgetl(fid);
if ~isempty(findstr(st,'LiveTM'))
ftell(fid)
g = cell2mat(textscan(fid,'%5d'))
end
end
The value it read is not correct.And I don't know how two make the 'EvtTime' as a vector. Could you please help me to solve the problem ? Many thanks in advance.
Have a gread day
AshleyXinying Dinghttps://au.mathworks.com/matlabcentral/profile/authors/9195050-xinying-dingtag:au.mathworks.com,2005:Question/4952172019-12-06T11:59:17Z2019-12-06T14:10:21ZAdding a Graph into a uipanel GUII am trying to add a graph into a uipanel that I have on my matlab GUI. I have a pushbotton that intakes information from empty text boxes and then after I use the push botton it makes a graph. I want to have this graph appear on my uipanel rather than a second window, is that possible or would I have to use a axis? I was planning on having adding a map into that panel as well, but later on.Erick Maganahttps://au.mathworks.com/matlabcentral/profile/authors/12044592-erick-maganatag:au.mathworks.com,2005:Question/4952372019-12-06T14:09:06Z2019-12-06T14:09:06ZIs Simulink build something like .exe from our model?hi guys
In every model which are creating in Simulink are consist of some blocks and wires, I think blocks are shared library in the backend of Matlab, now I would like to know are those wires are shared library like blocks?
another question is:
when we click on the play icon, we can see something in the taskbar which shows, compiling... my question is, Is at this phase Matlab building .exe file that containing those shared libraries?
Farshad Gholamihttps://au.mathworks.com/matlabcentral/profile/authors/7784609-farshad-gholamitag:au.mathworks.com,2005:Question/4897002019-11-06T05:00:00Z2019-12-06T14:07:01ZIs MATLAB compatible with macOS Catalina?Does MATLAB support macOS Catalina (10.15)?
MathWorks Support Teamhttps://au.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-team