https://fr.mathworks.com/matlabcentral/answers/questionsMATLAB Answers — New Questions2019-10-21T15:19:19Ztag:fr.mathworks.com,2005:Question/4861852019-10-18T16:55:22Z2019-10-21T15:19:19ZHow to edit original data in for-each equivalent statementI'm working with nested classes for Object Oriented Programming (OOP) and trying to find a cleaner way of doing things. For example, the following code is a function of a class Attacker which is a pain to read where Attacker has a property filtered_database which is a class which has vulns which has profile which has props which has scaled_value. Embedded classes like this are the norm for OOP, but using an indexed iteration scheme is just not nice and when you have 1000 lines of code the migranes set in.
% Loop through each vulnerability
for i=1:length(obj.filtered_database.vulns)
temp_profile = obj.filtered_database.vulns(i).profile;
% Scale each property
for j=1:length(temp_profile.props)
scaled_val = obj.ScaleProperty(temp_profile.props(j));
obj.filtered_database.vulns(i).profile.props(j).scaled_value = scaled_val;
end
end
So I'm trying to use the more functional component of the for loop. Take the example:
People = {'Joe', 'Bill', 'Ted'}
for person = People
person = strcat(person,' Foo');
end
People
If we were in python, person would be recognized as a linked part of the People object within the for-loop, meaning any changes I make to person would be reflected in People after completion of the for-loop, but this is not the case in Matlab. Now, in order to update the values in People, I need some sort of counter to keep track of which item in People I'm looking at. Is there a standard way of modifying the value in People in the loop as you would in Python without a counter? Any help would be appreciated.C Deloghttps://fr.mathworks.com/matlabcentral/profile/authors/9580024-c-delogtag:fr.mathworks.com,2005:Question/4865732019-10-21T13:31:15Z2019-10-21T15:18:41ZResampling two signals to the same sampling time and lengthHi guys !
For further system analysis I need to adapt two signals to the same length and sampling time. The signals are measured outputs of the system and the underlying input signals. They are sampled as follows:
t_input = 5ms
t_output = 2ms
Consequently, the signal vectors are of different lengths, too. My goal is to resample the signals to the output sampling time of t_output = 2ms and to make them equal-length. As an interpolation I want to use a linear interpolation. I have tried different methods and wrote functions to obtain the results, but have not been successful for days now. I used interp1 to interpolate between the input signal values, but it either didn't work or I haven't been able to make it work. I now seek help from you guys to fight this task! I do not want to use the matlab resampling function!
I have attached the input signal sine_input and the output signal sine_output. They consist of two columns, the first is the time stamp vector, the second column contains the measured output values or given input values, respectively.
I hope you guys can help !!!
Thank YOU !Aladin Djuherahttps://fr.mathworks.com/matlabcentral/profile/authors/11364632-aladin-djuheratag:fr.mathworks.com,2005:Question/4865892019-10-21T15:13:48Z2019-10-21T15:16:19Z[Appdesigner] How to fit a part of an video stream in app.UIAxes (i.e. zoom in)?Hi,
I am trying to zoom in on an object in an video stream. Im am using ROIPosition to only choose a part of the video object, like below. I basically only want to show a zoomed in part of the image.
Changing 'pbaspect' seems to only change the size of my UIAxes window.
The code below only seem to add the image of size (331,231), but does not fill complete volume of the UIAXes box. It leaves a huge white space at the bottom. I want the video content (330; 231) to fill the size of the UIAxes window of size app.vidRes(1), app.vidRes(2).
YOffset = 904;
XOffset = 476;
Height = 330;
Width = 231;
app.VidObj.ROIPosition = [YOffset XOffset Height Width];
% Setting the size of app.UIAxes
app.vidRes = app.VidObj.VideoResolution; % vidRes(2) vidRes(1)
app.nBands = app.VidObj.NumberOfBands;
% These lines set proper aspect ratio
app.UIAxes.XLim = [0, Width];
app.UIAxes.YLim = [0,Height];
app.UIAxes.XTick = [];
pp.UIAxes.YTick = [];
pbaspect(app.Video,[app.vidRes(1), app.vidRes(2), app.nBands]);
help, how can I do this?Happy PhDhttps://fr.mathworks.com/matlabcentral/profile/authors/12852222-happy-phdtag:fr.mathworks.com,2005:Question/4865922019-10-21T15:15:31Z2019-10-21T15:15:31ZHow to publish results from the command window in MATLABHi,
I ran a code it took 5 hours to give me results in the command window now I want to print the results from the command window as a pdf whenever I try to click on print then choose microsoftprint to pdf. The output file is not a pdf file!Cantor Sethttps://fr.mathworks.com/matlabcentral/profile/authors/14440086-cantor-settag:fr.mathworks.com,2005:Question/4865772019-10-21T13:43:15Z2019-10-21T15:15:30ZVarargout - How to realize function callHey guys,
let us assume the following function:
function [out1,out2,out3]=test(j,k)
out1= nargin;
out2 = j-k;
if out2 == 10
out3 = 5;
end
end
The function call [val1,val2,val3] = test(10,11) returns an error because c is obviously undefined. How do I make this code run so that out3 is returned when it exists?
Thanks for your help!Dario Walterhttps://fr.mathworks.com/matlabcentral/profile/authors/13904638-dario-waltertag:fr.mathworks.com,2005:Question/4865912019-10-21T15:14:05Z2019-10-21T15:14:05ZSawtooth Waveform With Variable Frequency and constant amplitude How can I create a sawtooth wave with external inputs such as constant amplitude (2*Pi) and variable frequency in simulink?
Ranjit Kumar Chennamchettyhttps://fr.mathworks.com/matlabcentral/profile/authors/15751706-ranjit-kumar-chennamchettytag:fr.mathworks.com,2005:Question/4865902019-10-21T15:14:00Z2019-10-21T15:14:00ZError 97 claims daemon server is down. Next step?When I call MATLAB to open, I get an error 97 that states that the daemon server is down. What is the fix?Paull Wozniakhttps://fr.mathworks.com/matlabcentral/profile/authors/16636454-paull-wozniaktag:fr.mathworks.com,2005:Question/4863542019-10-20T01:57:29Z2019-10-21T15:06:48Zread a matrix from a text fileim trying to read a text file containing matrix
A = readmatrix('output1.txt','Whitespace',' []'); when i execute it
its displaying
NaN NaN
NaN NaN
NaN NaN
NaN NaN
here output1.txt file contains data in the given manner
[[0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0
1 0 0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0]
[1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 1 0 1]
[0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0]
what else changes can i make .Nitish Reddy Kotkurhttps://fr.mathworks.com/matlabcentral/profile/authors/16284860-nitish-reddy-kotkurtag:fr.mathworks.com,2005:Question/4602402019-05-04T14:29:11Z2019-10-21T15:04:46ZHow to apply majority voting for classification ensemble in Matlab?I have five classifiers SVM, random forest, naive Bayes, decision tree, KNN,I attached my Matlab code. I want to combine the results of these five classifiers on a dataset by using majority voting method and I want to consider all these classifiers have the same weight. because the number of the tests is calculated 5 so the output of each classifier is 5 labels(class labels in this example is 1 or 2). I'll be gratefull to have your opinions
clear all
close all
clc
load data.mat;
data=data;
[n,m]=size(data);
rows=(1:n);
test_count=floor((1/6)*n);
sum_ens=0;sum_result=0;
test_rows=randsample(rows,test_count);
train_rows=setdiff(rows,test_rows);
test=data(test_rows,:);
train=data(train_rows,:);
xtest=test(:,1:m-1);
ytest=test(:,m);
xtrain=train(:,1:m-1);
ytrain=train(:,m);
%-----------svm------------------
svm=svm1(xtest,xtrain,ytrain);
%-------------random forest---------------
rforest=randomforest(xtest,xtrain,ytrain);
%-------------decision tree---------------
DT=DTree(xtest,xtrain,ytrain);
%---------------bayesian---------------------
NBModel = NaiveBayes.fit(xtrain,ytrain, 'Distribution', 'kernel');
Pred = NBModel.predict(xtest);
dt=Pred;
%--------------KNN----------------
knnModel=fitcknn(xtrain,ytrain,'NumNeighbors',4);
pred=knnModel.predict(xtest);
sk=pred;
how can I apply majority voting directly on these outputs of classifiers in Matlab?
Thanks very muchphdcomputer Enghttps://fr.mathworks.com/matlabcentral/profile/authors/12712473-phdcomputer-engtag:fr.mathworks.com,2005:Question/4865872019-10-21T15:02:56Z2019-10-21T15:04:34ZRV-M1 inverse kinematicsHi! I am trying to instruct RV-M1, a 5-DOF manipulator, to write the letters EEE on a paper. First, I explicitly defined the points of all vertices of EEE, including the intermediate points when traversing the spaces between each E. Next, I defined the cost function with inputs joint angles and defined points, cost(joint_angles,defined_points). The cost function is defined as the square of the difference between computed points and the explicitly defined points. That is, cost = (computed - defined)^2. The computed points are computed using the forward kinematic equations. I now feed the defined points to fmincon. The parameters of fmincon are:
Aeq = [0 1 1 1];
beq = 0
lower and upper bounds of the four joint angles, the last angle is always zero
lb = [-145; -25; -105; -85]
ub= [145; 95; 0; 85]
initial_angles = [0 0 0 0]
fmincon(@(joint_angles) cost(joint_angles, defined points), initial_angles,[],[],Aeq,beq,lb,ub)
However, the joint space I'm getting does not correspond to my explicitly defined points. Where am I wrong? I am happy to send my code if someone can help me.Jose Maria Bragahttps://fr.mathworks.com/matlabcentral/profile/authors/6300953-jose-maria-bragatag:fr.mathworks.com,2005:Question/4865882019-10-21T15:03:52Z2019-10-21T15:03:52ZSolve System with many variablesHello,
I am trying to solve a system of 100+ equations simultaneously. All of these equations are independent, meaning they do not rely on each other at all. I am trying to determine a way to neatly express and solve this problem using a nonlinear solver. I want something to the effect of F(X)=0 for x in X, where there are about 100 xs, using a nonlinear solver.
I could theoretically code everything out by hand, but I was wondering if anyone else had a more elegant solution?
Bayes_Factorhttps://fr.mathworks.com/matlabcentral/profile/authors/8748155-bayes_factortag:fr.mathworks.com,2005:Question/4863082019-10-19T17:32:39Z2019-10-21T15:02:30ZUnable to save/load objects created by App designer ? (R2019a)Hi, I'm using App Designer to build an app with a uitree and a uitable. The tree/table is editable in the app during runtime. I want the edited tree/table to be saved to a local place, and also be able to be loaded in the future. So I created the save/load buttons to save/load the uitree/uitable as the following (Tree as example):
function Button_Save(app, event)
ProgramTree=app.Tree;
uisave('ProgramTree','TreeSave')
end
function Button_Load(app, event)
ProgramTree= load('TreeSave.mat');
app.Tree=ProgramTree;
end
But warning shows "Unable to save/load the object created by App designer" and the process is not working. It seems Matlab has banned the save/load function for objects created by Appdesigner. I'm wondering if there is a way to walk around this, or is there anyway to extract the information of uitree to some other type of file, maybe .xls, for reuse? Thank you for reading.
Insohttps://fr.mathworks.com/matlabcentral/profile/authors/11944257-insotag:fr.mathworks.com,2005:Question/4864052019-10-20T14:44:44Z2019-10-21T14:59:12Zdisplay file function crash%I want to display a file and according to the book, I wrote the display file function like below, but it always showed that 'something wrong happen'. I have no idea which I part I did the wrong programming.%
function DisplayFile(filename)
try
fid=fopen(filename);
if fid == -1
disp(sprintf('Unable to open file ''%s'' ',filename));
else
while ~feof(fid)
tline = fget1(fid);
disp(tline);
end
fclose(fid);
end
catch
fclose(fid);
disp('Something wrong happened');
endYu Liuhttps://fr.mathworks.com/matlabcentral/profile/authors/11328116-yu-liutag:fr.mathworks.com,2005:Question/4865862019-10-21T14:42:43Z2019-10-21T14:55:13Zhow to use predict and forecastHello Family,
I am trying to predict the class of future dataset: Unfortunately my code is completely misclassifying one class meaning there is a problem with the code.
This is the dataset:
https://drive.google.com/file/d/1tQdZ5XXQAECN6eahzhkt5xLpZA9eOyFk/view?usp=sharing
Here is the code I am currently using:
%D be the dataset
Data=D(1:500,1:end-1);
Data2=D(501:1000,1:end-1);
class_labels=D(1:500,6);
Data2labels=D(501:1000,6);
classification_model = fitcensemble(Data,'class_labels~var1+var2+var3+var4+var5')
cv = cvpartition(classification_model.NumObservations, 'HoldOut', 0.2);
cross_validated_model = crossval(classification_model,'cvpartition',cv);
Predictions_1 = predict(cross_validated_model.Trained{1},Data(test(cv),1:end-1));
Predictions_5 = predict(cross_validated_model{1}.Trained,Data2);
training_data = Data(training(cv),:);
labels = unique(class_labels);
Y = ismember(training_data.class_labels,labels{1});
Results_1 = confusionmat(cross_validated_model.Y(test(cv)),Predictions_1);
Results_5 = confusionmat(Data2labels,Predictions_5);DARLINGTON ETAJEhttps://fr.mathworks.com/matlabcentral/profile/authors/8753940-darlington-etajetag:fr.mathworks.com,2005:Question/4865782019-10-21T13:47:11Z2019-10-21T14:53:24ZTime-frequency spectral coherence analysis (desperate need of help)How is it possible in MATLAB to calculate Coherence as a function of time for two nonstationary signals (EEG) as shown on the below image. I want to genereate a similar one in matlab. Can someone please help me. I am very new to matlab so a code will help.
Below are the equations for coherence. I have read that a multitaper moving window can be used. For this application, a 300 ms multitaper moving window can be used in time steps of 10 ms. I dont know how to implent it in matlab.
Hinna Ahmedhttps://fr.mathworks.com/matlabcentral/profile/authors/6904558-hinna-ahmedtag:fr.mathworks.com,2005:Question/4865852019-10-21T14:40:12Z2019-10-21T14:50:37ZHow to define variables automaticallyHello
I want to define some variables automatically say x1, x2, x3.... and want to assign inputs given by user to them automatically, can someone help?Sachin Dighehttps://fr.mathworks.com/matlabcentral/profile/authors/16061754-sachin-dighetag:fr.mathworks.com,2005:Question/4865792019-10-21T13:52:07Z2019-10-21T14:50:36ZHow to merge multiple xyz files into 1 large arrayI have a set of 501 XYZ files which I load in as
for k = 1:501
% AIS SEC data
AIS_SEC{k} = importdata(['AIS_SEC(' num2str(k) ').xyz']);
end
This generates an 1x501 cell array in which all data are stored (see attachment). How can I merge all these data to have 1 large XYZ file?
For example, to concentrate X data, I tried:
for k = 1:501
my_field = sprintf('X%d', k);
variable.(my_field) = ([AIS_SEC{1,k}.data(:,1)]);
end
BUT: Dot indexing is not supported for variables of this type.
Thanks!Yoni Verhaegen -WE-1718-https://fr.mathworks.com/matlabcentral/profile/authors/11287022-yoni-verhaegen-we-1718tag:fr.mathworks.com,2005:Question/4865602019-10-21T12:07:08Z2019-10-21T14:42:06ZSolving first order differential equationHello, I've tried multiple times to solve the following differential equation in Matlab but no luck so far. I have about 131 different values of U for 131 seconds of time t. A, B, r are constants, y and dy/dt has initial conditions of 0. I want to calculate L for each time t and plot a graph.
I've tried using ode23 and created a function. But it doesn't work. Any help in coding this in Matlab would greatly appreciated as I'm getting desperate! Thank you very much.Saruultugs Batzorighttps://fr.mathworks.com/matlabcentral/profile/authors/14132098-saruultugs-batzorigtag:fr.mathworks.com,2005:Question/4608622019-05-08T07:18:45Z2019-10-21T14:39:26Zhow to change the default frequency of aurdiuno pwm block of simulink support package for aurdiuno?Hi, the default frequency is 490Hz and i need set PWM frequency=10KHz, how to change the default frequency of aurdiuno pwm block of simulink support package for aurdiuno?shivaleela patilhttps://fr.mathworks.com/matlabcentral/profile/authors/13128495-shivaleela-patiltag:fr.mathworks.com,2005:Question/4850432019-10-13T14:56:14Z2019-10-21T14:35:13ZPx4 Support for Embedded Coder - pixhawk not configured correctlyTrying to get simulink writing to my pixhawk 4 on 2019b, windows 10.
I am able to compile, upload, and connect with external mode. I can even read inputs from my RC radio or show gyro values on scopes/displays. HOWEVER:
I cannot, for the life of me, arm the PWM outputs so that I can actually use them. "px4demo_PWM", does not work for me, and any number of changes I cannot seem to get to work. If I power everything down, move the servos somewhere, and then power everything up, the servos always move to the "failsafe" positions after initialization. I can even change the failsafe position and get the servos to move there instead, but I cannot command out normally despite the failsafe being set to off and ARM enabled.
Looking at "actuator arming" the actuators are not, in fact armed, so I tried manually doing a uORB write to force it to an armed state. It showed armed, not on failsafe, not lockdown, etc., but no commands could get out.
After much troubleshooting and banging my head on the table I eventually came to realize the RGB LED flashing red and determined that means the pixhawk is "not configured correctly". Would I be correct in guessing this is why it refuses to arm? Fundamentally my primary question is "how do I get my pixhawk to drive servos normally?" but there are numerous follow up questions:
Is this potentially an issue with my hardware or is this part of the normal setup? Are you supposed to load the normal px4 firmware in QGC, configure it normally in QGC, including calibration and such, and then come back to simulink and use embedded coder? Is there a way to change configuration parameters without using QGC? What parts of the PX4 flight stack are being overriden when you load a custom simulink app (if any)?
I'm trying to understand where the line is between the core flight stack and the app i'm trying to run on top of it. Preferrably, I would handle arming myself within my app and not have to deal with all these other checks that PX4 is natively doing behind the scenes. Is there a way in the "rc.txt" file to basically say "let simulink_app handle everything, pipe all raw sensor data to it, run all outputs from it, no questions asked?" But, at the same time, the core flight stack appears to be generating a navigation solution that you can easily tap into using a uORB read, and I want to be able to leverage that.
I know that's a spew of questions, sorry about that. Please provide any clarification you can, thanks!
Kevin Hainlinehttps://fr.mathworks.com/matlabcentral/profile/authors/13261318-kevin-hainlinetag:fr.mathworks.com,2005:Question/4865832019-10-21T14:21:34Z2019-10-21T14:30:58ZHow do I plot a constant value over multiple different intervals ?doubleArray = getaudiodata(rec);
plot(doubleArray);
title('Audio Signal of "Hello World"');
xlabel('Time t');
ylabel('Signal Amplitude x');
hold on %Getting them on same plot
grid on
Squared_Sig = doubleArray.^2; %Squaring all the vaules in the array
b = reshape(Squared_Sig,[],50); %Divides the square signal into 20msec
%chunks by divideing total samples by
%100, each one has 160 elements
partSum = sum(b); % Sum of each of the 100 parts
Average_power = partSum./160;
Here you can see I have the average power for each of the 100 sections of the original signal. How do I create a CT plot of the average power of these sections on the same plot as the original signal ???
Aaron Richardshttps://fr.mathworks.com/matlabcentral/profile/authors/14537157-aaron-richardstag:fr.mathworks.com,2005:Question/4865842019-10-21T14:26:53Z2019-10-21T14:29:26ZOutput must be a column vectorI can't get this function to output a vector.
function dPdq = dPdq (t, y)
global Vd Tc Rv r_ar Qin p PI deltaq dPdq
A_weibe=5;
B_weibe=3;
R=8.314;
m=6;
PCI=2.772e7;
P=y;
q=t
Qs=340;
Qb=60;
for q=PI:(PI+deltaq)
% Volume
V(q)=Vd/(Tc-1)+(Vd/2)*(Rv+1-cos(q)-sqrt(Rv^2-(sin(q))^2));
% dVdq
dVdq(q)=(Vd/2)*sin(q)*(1+cos(q)*(Rv^2-(sin(q))^2)^-0.5);
if ((q>=Qs)&&(q<Qs+Qb))
F(q)=1-exp(-A_weibe*((q-Qs)/Qb)^B_weibe)
dFdq(q)=B_weibe*A_weibe/Qb*(1-F(q))*((q-Qs)/Qb)^(B_weibe-1)
dPdq(q)=-r_ar*(P/V(q))*dVdq(q)+(r_ar-1)*((Qin/V(q))*dFdq(q))
else
dPdq(q)=-r_ar*(P/V(q))*dVdq(q);
end
end
I tried simply callling:
dYdq(1)=dPdq ---- no success
dYdq(:)=dPdq(:) ----- no success
for i=1:400
dy(i,1)=dPdq(i);
end ------------------------no success
I have no ideas left, do you have any insights?
Rafael Marcelinohttps://fr.mathworks.com/matlabcentral/profile/authors/16636147-rafael-marcelinotag:fr.mathworks.com,2005:Question/4862192019-10-18T22:25:16Z2019-10-21T14:22:26ZBar plot axes size using text in X axisSo, I tried plotting a bar plot for an array with 25 items. I linked it with a unique string on the X-axis, but when I plot the Bar plot - I cannot see all the unique values eventhough I tried rotating the axis to 90 deg, reduced size of gca. Attached my code!
Basically, I want a unique value seen in my x axis corresponding to the value in Y axis (display of all X axis values).
How can I achieve this?
Abhinav Karthik Sridharhttps://fr.mathworks.com/matlabcentral/profile/authors/16614633-abhinav-karthik-sridhartag:fr.mathworks.com,2005:Question/4865822019-10-21T14:21:32Z2019-10-21T14:21:32ZIs DenseNet-201 supported by the Matlab compiler?I have a DenseNet-201 model that has been trained for classification and it keeps displaying errors when trying to run the compiled '.exe'.
Error: Dot indexing is not supported for variables of this type.
This error is from the line that classifies images using the DenseNet model. Is the DenseNet-201 model supported for the compiler. I see that it is not supported for code generation https://www.mathworks.com/help/coder/ug/networks-and-layers-supported-for-c-code-generation.html .
Kyle Petersonhttps://fr.mathworks.com/matlabcentral/profile/authors/14313254-kyle-petersontag:fr.mathworks.com,2005:Question/3100392016-10-31T22:11:48Z2019-10-21T14:21:16ZHow to change the color of individual bars in a bar chart?Make a simple bar chart (and get its handle):
figure
rng default
hb = bar(rand(1,3));
How can I set the colors of those bars now (after I have made the figure)? I want each bar to be a _different_ color.
I am specifically asking about MATLAB R2016b.
<</matlabcentral/answers/uploaded_files/62352/test.png>>
I asked a <http://www.mathworks.com/matlabcentral/answers/162607-how-to-change-the-color-of-the-bars-in-a-bar-chart very similar question about MATLAB R2014b> earlier, but that method no longer seems to work. (Or I am overlooking something again.
the cyclisthttps://fr.mathworks.com/matlabcentral/profile/authors/1841757-the-cyclisttag:fr.mathworks.com,2005:Question/4864922019-10-21T03:49:26Z2019-10-21T14:21:12ZParker/Gambrel Truss Algorithm- undefined function or variable 'm' I kept getting a 'preallocating for speed error' on line 73 for r(m).
I solved that issue by setting:
r(m) = zeros; %(before the for loop function)
NOW I'm getting an 'undefined function or variable 'm' error' on line 65.
NEED to make this code plot a Parker/Gambrel truss like in the picture:
what is wrong with my code?
clear, clf, clc
choice1=menu('Truss Program would like you to enter truss dimensions manually and define its dimensions?'...
,'Enter Dimensions Manually');
switch choice1
case 1
J=input('Please enter the number of joints:\n');
M=(2*J)-3; %Joint-member relationship for a simple, planar truss.
C=zeros(J,M); %Preallocates the connection matrix
x=zeros(J,1); %Preallocates the joint position vectors
y=zeros(J,1); %Prompts user for coordinates for joint positions through a loop
for j=1:J
promptx=sprintf('Please enter the x coordinate of joint %d in FEET:\n',j);
x(j)=input(promptx);
prompty=sprintf('Now enter the y coordinate of joint %d in FEET:\n',j);
y(j)=input(prompty);
end
%Builds the connection matrix from a loop of queries asking the
%user which members are connected to each joint.
cnct{1,J}=[]; %Each cell in 'cnct' contains the indices of the corresponding row in connection matrix 'C' that are to be assigned the value of 1.
for j=1:J
str=sprintf('How many members are connected to joint %d?\n',j);
choice2=menu(str,'1','2','3','4','5','6');
cnct{j}=zeros(choice2,1);
for i=1:choice2
rem=choice2-(i-1);
str2=sprintf('Which members? (%d members remaining for joint %d.)\n',rem,j);
cnct{j}(i)=input(str2);
end
C(j,cnct{j})=1;
end
end
%--------------------DEFINE SUPPORT AND LOAD MATRICES---------------------%
tstart=tic;
%Creates support force connection matrix
Sx=zeros(J,3);
Sy=zeros(J,3);
Sx(1,1)=1;
Sy(1,2)=1;
Sy(J,3)=1;
%Creates a load vector describing the location and strength of the
%load on the truss
L=zeros(2*J,1);
choice3=menu('Would you like to set a load at a joint?','Set a Load');
switch choice3
case 1
Lj=input('What number joint will the load be placed at?\n');
F=input('Please enter the value of the load in Newtons: \n');
L(J+Lj)=F;
end
%---------------------CONSTRUCT EQUILIBRIUM EQUATIONS---------------------%
%Preallocation
deltax=zeros(M,1);
deltay=zeros(M,1);
ux=zeros(M,1);
uy=zeros(M,1);
Ax=zeros(J,M);
Ay=zeros(J,M);
r=zeros(1,M);
%Calculates coefficients for matrix A.
for m=1:M
vec=find(C(:,m));
deltax(m)=abs(x(vec(2))-x(vec(1)));
deltay(m)=abs(y(vec(2))-y(vec(1)));
r(m)= magnitude(deltax(m),deltay(m));
ux(m)=deltax(m)/r(m);
uy(m)=deltay(m)/r(m);
if x(vec(1))<x(vec(2))
Ax(vec(1),m)=ux(m);
Ax(vec(2),m)=-ux(m);
else
Ax(vec(1),m)=-ux(m);
Ax(vec(2),m)=ux(m);
end
if y(vec(1))<y(vec(2))
Ay(vec(1),m)=uy(m);
Ay(vec(2),m)=-uy(m);
else
Ay(vec(1),m)=-uy(m);
Ay(vec(2),m)=uy(m);
end
end
A=[Ax Sx;Ay Sy]; %Creates matrix A
T=A\L; %Solves equilibrium equations
%--------------------------ANALYSIS OF RESULTS----------------------------%
f=plottruss(x,y,C,critmember,Lj);
set(f,'Visible','on','Name','NameTest')Ruben Morahttps://fr.mathworks.com/matlabcentral/profile/authors/15446984-ruben-moratag:fr.mathworks.com,2005:Question/4865812019-10-21T14:12:42Z2019-10-21T14:19:49ZChange Matlab Version from R2014a to R2018ai have a students licence of the R2014a version, but i want to change it to the R2018a version. How should i proceed? also, i cant find a way to uninstall the 2014 version. I have windows 10 but i dont see matlab on the control panel and i cant find the uninstall.exe in the Matlab folderFederico Casalihttps://fr.mathworks.com/matlabcentral/profile/authors/16454931-federico-casalitag:fr.mathworks.com,2005:Question/4066682018-06-20T22:43:54Z2019-10-21T14:19:18ZConnecting to ThorLabs PAX1000 Polarimeter using Test & Measurement Tool Greetings,
I have a ThorLabs PAX1000 polarimeter connected via USB to a 64 bit Windows 7 machine running Matlab R2015a 64bit. I am attempting to use Matlab to automate some measurements. The vendor software is working fine which implies that the drivers are installed correctly. However, I don't see any drivers for the device listed in the Test & Measurement Tool.
I have attached the section of the device manual which discusses the driver files, and a screen shot from the Test & Measurement Tool where you can see that the device is detected under USB, but no PAX drivers are listed.
Is it possible to use the VXI drivers with Matlab for this device, if so, how do I proceed?
Thanks,
RyanRyanhttps://fr.mathworks.com/matlabcentral/profile/authors/3250309-ryantag:fr.mathworks.com,2005:Question/4864882019-10-21T03:00:27Z2019-10-21T14:15:33ZHow to break or split a line at NaN points in 1x15000 csv file?i have a csv file (1x15000) which needs to be splitted at specific points(NaN).
Roobini Vijayabalanhttps://fr.mathworks.com/matlabcentral/profile/authors/16466335-roobini-vijayabalantag:fr.mathworks.com,2005:Question/4865632019-10-21T12:19:37Z2019-10-21T14:14:15ZUploading a value with a Matrix into MATLAB GUIHello Guys. I hope you are doing well. I have a question related to the uploading the value with a matrix. My code for the upload_ callback is working for all values except for the edit text box with a matrix and a value. How can I change the code below so that I can upload the value with the matrix as well? Any help will be greatly appreciated. I get the following errors when I use the pushbutton upload code shown below. These errors only come when I try to upload the value with the matrix edit box and not for the other edit text boxes.
Error using sprintf
Function is not defined for 'cell' inputs.
Error in GUI_ParametersFinal>pushbutton_Upload_Callback (line 149)
evalstr = sprintf('set(handles.%s,''%s'',''%s'')',uictagnames{i}, uicparams{j},tempval);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in GUI_ParametersFinal (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)GUI_ParametersFinal('pushbutton_Upload_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback
The code is:
function pushbutton_Upload_Callback(hObject, eventdata, handles)
startingFolder = pwd
defaultFileName = fullfile(startingFolder, '*.mat');
[baseFileName, folder] = uigetfile(defaultFileName, 'Select a mat file');
if baseFileName == 0
return;
end
fullFileName = fullfile(folder, baseFileName)
temp = load(fullFileName);
data=temp.data;
uictagnames = fieldnames(data);
for i =1:numel(uictagnames)
uicparams = fieldnames(data.(uictagnames{i}));
for j = 1:numel(uicparams)
tempval = data.(uictagnames{i}).(uicparams{j});
if ~isnumeric(tempval)
evalstr = sprintf('set(handles.%s,''%s'',''%s'')',uictagnames{i}, uicparams{j},tempval);
else
evalstr = sprintf('set(handles.%s,''%s'',%d)',uictagnames{i}, uicparams{j}, tempval);
end
evalc(evalstr);
end
end
For edit callbacks, I am using this code:
str=get(hObject,'String');
tagname=get(hObject,'tag');
handles.mystructdata.(tagname).string = str;
guidata(hObject,handles)
The value in the edit text box is being generated from another GUI in the button down function. The value is getting saved, but once I click on the upload button, all the values get uploaded except for the value shown below because it is a value with matrix. You can see that below:
For all other structs, I have 1 fields. Only for this struct, I have 2 fields. Any help will be greatly admired as I am working on a big project. I had taken the help for uploading the values of the edit text boxes from this link. Therefore, you can see the link as well. I just need to upload the value with the matrix as shown above. Everthing else is done.
https://uk.mathworks.com/matlabcentral/answers/115235-store-permanently-data-taken-from-an-edit-text-box-of-gui
MHShttps://fr.mathworks.com/matlabcentral/profile/authors/12763488-mhstag:fr.mathworks.com,2005:Question/4865472019-10-21T11:06:44Z2019-10-21T14:13:05ZHow many times does each combination of numbers appear? Let's say I ran randi(1-40) to produce 5 columns and 100 rows
Would I be able to get it to tell me how many times, 1 and 2, for example, come up in the same row. Then if not how may times another combination would come up like 3 and 4 for example?
Thanks everyone for any help
Jake Mcgeehttps://fr.mathworks.com/matlabcentral/profile/authors/12578955-jake-mcgeetag:fr.mathworks.com,2005:Question/4865682019-10-21T13:12:22Z2019-10-21T14:11:34ZHow do i assigning a color to a range of numbers in an image array?I am currently attempting to assign the color red to all the negative values in an 2D array and the color green to all the positive values in an 2D array. If the value is 0, i want the color displayed to be yellow. The background value should be white.
Example array:
A = [ 9899 9899 9899 9899 9899
9899 -90 0 70 9899
9899 9899 -20 30 9899
9899 9899 9899 9899 9899];
9899 represents the background color, which should be white. The zeros should be yellow. All colors should be uniform and there should not be a color gradient.
I would expect an output colormap that looks similar to this(without labels):
I have tried the imagesc function but i do not know how to set up the proper ranges/limits for the desired colors to appear.
I would greatly appreciate any feedback. Thank you in advance!
Stoph Xhttps://fr.mathworks.com/matlabcentral/profile/authors/13106731-stoph-xtag:fr.mathworks.com,2005:Question/4849722019-10-13T00:30:18Z2019-10-21T14:11:23ZSuggestions for predicting the displacement of a graph or force estimation.Hello
This question is aimed mostly to engineers but whoever believes he can handle it may give his valuable advice.
I have a tabular data set of Load/Displacements in Newton/mm of a material using an Instron Machine, applying compressive forces.
Those data are my reference or gold standard. The same material is depicted on images where unknown forces are applied to the object and the object deforms as it is a rubber material. I want to estimate the forces caused that deformation.
My idea is developing a model that measures each column of the image that the object is depicted under strain. I measure the heigh of the object in each image column and find the difference from the gold standard that I have. Sounds simple right? I was thinking an interpolation method to bridge the gaps between the gold standard and the measured data from the images. E.g. if the gold standard data for 5 Newton is 2 mm displacement from its original position (undeformed material), then how many newtons are required to displace the same object at 5 mm from its original position. Something like that.
Can you help with suggestions and ideas please?
Thanks in advance
Stelios Fanourakishttps://fr.mathworks.com/matlabcentral/profile/authors/10865530-stelios-fanourakistag:fr.mathworks.com,2005:Question/4865712019-10-21T13:18:44Z2019-10-21T14:09:27ZVectorisation of code for insertion of n x n matrices in a 3D array along the diagonal of a large matrix I am trying to insert small square matrices along the diagonal of a large matrix. These matrices are contained in a 3D array, and have different values. Overlapping values are to be added, and the small matrices are only inserted where they can fit fully inside the large matrix. The step dimension will always be equal to 1.
I have achieved an answer through the use of for-loops, but am attempting to vectorise this code for efficiency. How would I do this? The current, unvectorised code is shown below.
function M = TestDiagonal2()
N = 10;
n = 2;
maxRand = 3;
deepMiniM = randi(maxRand,n,n,N+1-n);
M = zeros(N);
for i = 1:N+1-n
M(i:i+1,i:i+1) = M(i:i+1,i:i+1) + deepMiniM(:,:,i);
end
end
The desired result is an `N`x`N` matrix with `n+1` diagonals populated:
3 1 0 0 0 0 0 0 0 0
4 5 3 0 0 0 0 0 0 0
0 3 3 3 0 0 0 0 0 0
0 0 1 6 3 0 0 0 0 0
0 0 0 4 4 4 0 0 0 0
0 0 0 0 2 3 2 0 0 0
0 0 0 0 0 2 6 2 0 0
0 0 0 0 0 0 4 2 2 0
0 0 0 0 0 0 0 3 3 1
0 0 0 0 0 0 0 0 3 3Jason Traceyhttps://fr.mathworks.com/matlabcentral/profile/authors/14100707-jason-traceytag:fr.mathworks.com,2005:Question/4865802019-10-21T14:08:22Z2019-10-21T14:08:22ZHow can i improve my script which links matlab to xplane 11Ive written a Matlab code which can be used to control X- plane 11.
i was jsut wondering if there are any ways for me to improve this script so it functions better
Really need some help with this! the script is as folloows
%Provides a way of controlling the A/C surfaces and reading their values
%It also allows logging of A/C parameters to MATLAB variables
%Uses xplane.m or xplane.p interface software created by JJL
%X-Plane Settings required to interface with this software:
%1) In "Data Output - General Data Output"
% a)tick the following
% "Network via UDP" settings: 1,3,4,8,9,11,12,13,14,17,20,26,37
% b)Under "NETWORK CONFIGURATION" tick "Send network data output" and
% set the IP address to 127.0.0.1 and the Port to 49003
% c)Under "Dataref Read/Write" nothing needs to be ticked
%2)Under the main menu heading "Network" set "UDP PORTS" to:
% a) "Port we receive on" = 49010
% b) "Port we receive on (legacy)" = 49000
% c) "Port we send from (legacy)" = 49001
% Note that the settings above are not clearly understood by myself
% so it could be that some settings are not neccessary but I just
% want to get some settings that work!
LogIteration = 0;
LoggedTime = 0;
LoggedElevators = 0;
LoggedAilerons = 0;
LoggedRudder = 0;
LoggedPitch = 0;
LoggedRoll = 0;
LoggedAltitude = 0;
%Create a window in which the data can be seen and changed
figure;
axes('Position',[0 0 1 1],'Visible','on');
%Create the various user interface controls needed
FrameHandle = uicontrol('Style','pushButton','String','break','Callback','delete(gcbf)');
RudderSlider = uicontrol('Style','slider','Min',-1,'Max',1,'Value',0,'Position',[20 75 160 20]);
AileronSlider = uicontrol('Style','slider','Min',-1, 'Max',1,'Value',0,'Position',[20 115 160 20]);
ElevatorSlider = uicontrol('Style','slider','Min',-1, 'Max',1,'Value',0,'Position',[20 158 160 20]);
ThrottleSlider = uicontrol('Style','slider','Min',0, 'Max',1,'Value',0,'Position',[20 200 160 20]);
BrakeButton = uicontrol('Style','radio','String','Brake On','Position',[20 240 100 30]);
Logging = uibuttongroup('Position',[0.03 0.7 0.3 0.25]);%,'SelectionChangedFcn',@bselection);
StartLogging = uicontrol('Parent',Logging,'Style','radio','String','Start Logging','Position',[25 25 100 15],'HandleVisibility','off','Value',0);
StopLogging = uicontrol('Parent',Logging,'Style','radio','String','Stop Logging','Position',[25 60 100 15],'HandleVisibility','off','Value',1);
%Continuously loop until "break" button pressed
while ishandle(FrameHandle)
%Get values from slider and biutton controls into "controls" structure
controls.elevator = ElevatorSlider.Value;
controls.aileron = AileronSlider.Value;
controls.rudder = RudderSlider.Value;
controls.throttle = ThrottleSlider.Value;
controls.brake = BrakeButton.Value;% 1=brakes on;
%Send control structure to xplane ands simultaneously collect data
%from xplane into "aircraft" structure
aircraft = xplane('send', controls);
cla; % Clear all editable views in the control frame
% Display the control values
t1 = text(0.35,0.4,sprintf("Elevator = %f",controls.elevator));
t1.FontName = 'Arial';
t2 = text(0.35,0.3,sprintf("Aileron = %f",controls.aileron));
t2.FontName = 'Arial';
t3 = text(0.35,0.2,sprintf("Rudder = %f",controls.rudder));
t3.FontName = 'Arial';
t4 = text(0.35,0.5,sprintf("Throttle = %f",controls.throttle));
t4.FontName = 'Arial';
t5 = text(0.35,0.6,sprintf("Brake = %f",controls.brake));
t5.FontName = 'Arial';
% Display the xplane variables stored in "aircraft"
t6 = text(0.6,0.5,evalc('disp(aircraft)'));
t6.FontName = 'Arial';
%If logging selected, store various aircraft values
if(StartLogging.Value == 1)
LogIteration = LogIteration + 1
LoggedTime(LogIteration) = aircraft.time;
LoggedElevators(LogIteration) = aircraft.elevator;
LoggedAilerons(LogIteration) = aircraft.aileron;
LoggedRudder(LogIteration) = aircraft.rudder;
LoggedPitch(LogIteration) = aircraft.pitch;
LoggedRoll(LogIteration) = aircraft.roll;
LoggedAltitude(LogIteration) = aircraft.altitude;
end
pause(0.5); %Pause to allow 2 data transfers per second
end
Jason Hookerhttps://fr.mathworks.com/matlabcentral/profile/authors/16635892-jason-hookertag:fr.mathworks.com,2005:Question/4862702019-10-19T11:21:13Z2019-10-21T14:01:03ZI am not getting the correct value for rblush in this code. here, red is a matrix consisting of only the r of rcb values of an image. If the value of red_pixel is greater than 200, i want to add the pixel values in rblush but im getting the wrong valfor x=1:rows
for y=1:columns
red_pixel= red(x,y);
if(red_pixel>=200)
if(red_pixel> rmean)
blush= blush+1;
rblush =sum(red_pixel);
end
end
end
end
%the value of rblush should be a big number but it only goes upto 255, how do i modify the code to achieve thisAishwarya Jayachandranhttps://fr.mathworks.com/matlabcentral/profile/authors/16237238-aishwarya-jayachandrantag:fr.mathworks.com,2005:Question/4864552019-10-20T20:14:59Z2019-10-21T13:59:04ZHow to plot different data sets from an excel sheet inside a for loop?My excel sheet has 20 200x200 matrices (that are temperature values) with 4 empty rows seperating every two matrices. In the following code, I intend to plot, one by one, each of the 200x200 matrices with a small pause in between to display the graphs (2D temperature profiles).
data=xlsread('2D unsteady Qgen.xlsx');
for j=1:204:3877
temp=data(1:end,j:(j+199));
pcolor(temp)
colorbar
pause(0.5);
end
grid off
I get the following error:
Index in position 2 exceeds array bounds (must not exceed 200).
Error in abi_2 (line 5)
temp=data(1:end,j:(j+199));
Is there any way I could achieve what I intend to?
Thank you.
Sincerely,
AbishekAbishek Shttps://fr.mathworks.com/matlabcentral/profile/authors/13628023-abishek-stag:fr.mathworks.com,2005:Question/4719882019-07-16T15:58:01Z2019-10-21T13:57:23ZDenseNet-201 DAGNetwork compilation problemHi,I'm new to MATLAB. I'm using MATLAB to perform transfer learning.
After using transfer learning based on densenet201, I get the DAGNetwork I need and I want to compile a recongnition program (.exe) using MATLAB.
Here is my recongnition program code (combinetest.m):
%MAIN PROGRAM
load('demo1');
while(1)
if (exist('00015.jpg','file') ~=0)
try
I=imread('00015.jpg');
catch
delete('00015.jpg');
continue;
end
m=fishrecon(I,net);
delete('00015.jpg');
fileID = fopen('result.txt','w');
fprintf(fileID,'%s',m);
fclose(fileID);
end
pause(0.5);
end
And fishrecon function (fishrecon.m):
function m=fishrecon(imd,net)
if (ischar(imd))
imd=eval(imd);
end
imd=imresize(imd,[224,224]);
[label,scores] = classify(net, imd);
classNames = net.Layers(end).ClassNames;
m=string(label)+ num2str(100*scores(classNames == label),3) + "%";
'demo1' is the DAGNetwork I got from transfer learning on densenet201.
I compile the MATLAB code with the build-in APP --Application Compiler,but after compilation the program keeps jumping out the error message.
It seems the code below went wrong.
m=fishrecon(I,net);
But the code works fine while using MATLAB editor.
Have anybody encountered this problem? Please help.
Will Yuhttps://fr.mathworks.com/matlabcentral/profile/authors/13095772-will-yutag:fr.mathworks.com,2005:Question/4865382019-10-21T09:55:09Z2019-10-21T13:57:20Zparking space using IMAGE PROCESSINGclc;
close all;
clear all;
%image acquisition
f=imread('C:\Users\vinoth\Downloads\jph.jpg');
f=imresize(f,[800 NaN]); % image loading unit
figure (1)
imshow(f)
g=rgb2gray(f);
g=medfilt2(g,[5 5]);
figure (2)
imshow (g)
% morphological image processing
conc=strel('disk',5);
gi=imdilate(g,conc);
conc1=strel('disk',5);
ge=imerode(gi,conc1); % morphological image processing
gdiff=imsubtract(gi,ge);
gdiff1=mat2gray(gdiff);
figure (4)
imshow (gdiff1)
gdiff2=conv2(gdiff1,[1 1;1 1]);
figure (5)
imshow (gdiff2)
gdiff3=imadjust(gdiff2,[0.4 0.9],[0 1],1);
figure (6)
imshow (gdiff3)
B=logical(gdiff3);
[a1 b1]=size(B);
figure(7)
imshow(B)
er=imerode(B,strel('line',60,8));
figure(8)
imshow(er)
out1=imsubtract(B,er);
F=imfill(out1,'holes'); %filling the object
H=bwmorph(F,'thin',0.5);
H=imerode(H,strel('line',8,55));
figure(9)
imshow(H)
%Normalization% & Object Recognition
I=bwareaopen(H,floor((a1/18)*(b1/18)));
I(1:floor(.9*a1),1:2)=1;
I(a1:-1:(a1-20),b1:1:(b1-2))=1;
figure(10)
imshow(I)
%Cars detection in image
figure (11)
imshow pair (f,I)
%Create bounding box on detected cars
Iprops=regionprops(I,'BoundingBox','Image');
hold on
text(8,785,strcat('\color{green}Cars Detected:',num2str(length(Iprops))))
hold on
for n=2:size(Iprops,1)
rectangle('Position',Iprops(n).BoundingBox,'EdgeColor','g','LineWidth',2);
end
result = sprintf('Number of cars: %d.',n-1);
disp(result);% display number of cars
hold off
i am trying to do a project for parking space detection using image processing , the above program is the code ive been working on, whenever i am trying to run the code , it shows an error like this
??? Error using ==> imageDisplayParsePVPairs at 72
Invalid input arguments.
Error in ==> imageDisplayParseInputs at 70
[common_args,specific_args] = imageDisplayParsePVPairs(varargin{:});
Error in ==> imshow at 199
[common_args,specific_args] = ...
i am not expert in matlab, i am a student trying to do a report on IMAGE PROCESSING if someone know what is the problem in this code?... if knew explain this to me.. i copied this code i didnt write this...vinoth bala Thttps://fr.mathworks.com/matlabcentral/profile/authors/15800336-vinoth-bala-ttag:fr.mathworks.com,2005:Question/4861452019-10-18T13:49:41Z2019-10-21T13:52:09ZUsing a loop and counter for parametric equationsI'm very new to MATLAB so I am aware this code is probably atrocious. Please speak clearly!
I have an equation for calculating wave power density (E) in an ocean wave. It has three variables (H, T, and h) with different numerical ranges. (i.e. H ranges from 1 to 3, T ranges from 5 to 22, and h ranges from 5 to 6.) I want to create a FOR loop where MATLAB will plug in different numbers, with increments of 1, essentially being a parametric study. I can't find any clear videos or links on nested for loops with counters.
Ex:
Landon Sugarhttps://fr.mathworks.com/matlabcentral/profile/authors/6060959-landon-sugartag:fr.mathworks.com,2005:Question/2545242015-11-12T05:00:00Z2019-10-21T13:49:51ZHow can I use C++ classes in my MATLAB functions and generate code using MATLAB Coder?I need to use class methods from an external C++ library in my MATLAB function as part of my workflow. How can I use C++ classes in my MATLAB functions and generate code using MATLAB Coder?
MathWorks Support Teamhttps://fr.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:fr.mathworks.com,2005:Question/4655472019-06-04T21:11:40Z2019-10-21T13:47:46ZSplit a column data into multiple columnsI have 1000 observations in a column.
I want to convert first 5 element in 1st row
next 5 element in 2nd row and
next 5 in 3rd row and so on....
Please someone told how can I split data. Abdul Ghaffarhttps://fr.mathworks.com/matlabcentral/profile/authors/12818169-abdul-ghaffartag:fr.mathworks.com,2005:Question/4865522019-10-21T11:28:25Z2019-10-21T13:47:25ZHow do you determine the average values in second column of an excel data corresponding to a particular range of values in first column ?I have an excel file which containes more than 300000 in both column a and b. If the values in first column is less than 1 ,I need to average the corrosponding values in the second column and then increasing the range to 1 to 2 and so on up to 30..Any help would be greatly appreciated. Thank you.
My file looks like this
2.2060 0.3120
2.2140 0.3138
2.2180 0.3146
2.2260 0.3164
3.8920 0.2611
3.9000 0.259
3.9070 0.2571
3.8840 0.2632
3.9600 0.2431
4.0010 0.2322
If the values in first column is less than 1 ,I need to average the corrosponding values in the second column and then increasing the range to 1 to 2 and so on up to 30..Any help would be greatly appreciated. Thank you.Duphrinhttps://fr.mathworks.com/matlabcentral/profile/authors/16063588-duphrintag:fr.mathworks.com,2005:Question/4826132019-09-28T14:29:30Z2019-10-21T13:46:44ZTransfer function from measured input signal and output signalDear Matlab and Simulink user,
Is there any way with parameter estimation toolbox or any another method to generate transfer function from multiple inputs and multiple outputs Signals?Ill chhttps://fr.mathworks.com/matlabcentral/profile/authors/16118453-ill-chtag:fr.mathworks.com,2005:Question/900142013-10-12T17:11:46Z2019-10-21T13:44:39Zhow we can define piecewise function in matlab?in maple we can use comamnd:(
f:= piecewise(0 <= t and t <= T1, f1, T1 < t and t < T2, 0, T2 <=t and t <= T3, f1, T3 < t and t < T4, 0)
but in matlab i can not define this function.
please give me som information ...
thanksebihttps://fr.mathworks.com/matlabcentral/profile/authors/4696178-ebitag:fr.mathworks.com,2005:Question/4865762019-10-21T13:40:48Z2019-10-21T13:41:33ZCan I use multiple responses in the regression learner app?I am using the regression learner app to train a model to find a position given a set of predictor variables. The position is two-dimensional. However, I cannot see how to use a vector or two varaibles as responses. Is this possible?
Thanks!Oscarhttps://fr.mathworks.com/matlabcentral/profile/authors/2313998-oscartag:fr.mathworks.com,2005:Question/4861222019-10-18T11:34:39Z2019-10-21T13:41:21ZPrecision/Recall (perfcurve)Hello,
My naive question is about the precision and recall rates that can be output from the perfcurve function.
As you may already know, this would look like:
[X, Y] = perfcurve(labels, score(:, 2), 'LowFlow', 'XCrit', 'prec', 'YCrit', 'reca');
X and Y, however, are vectors. Normally, what is reported in the literature is a single value. My question is, to get the precision/recall estimates, should I take the mean of the non-NaN values from X (= precision) and the mean of the non-NaN values from Y (= recall) or is there another computation involved into getting a single value that represents these rates?
Thank you for your help.Baiumhttps://fr.mathworks.com/matlabcentral/profile/authors/13406043-baiumtag:fr.mathworks.com,2005:Question/4865752019-10-21T13:38:59Z2019-10-21T13:38:59ZHow can i find the experimental and theoritical BER ? Hello ,
i am given r[k]=h[k]s[k]+awgn , k=1,...N(N=100) where s[k] is a 4-QAM modulation and h[k] is a flat fading channel . How can i find the experimental and theoritical BER ? How can i find the experimental and theoritical BER ? I am given snrdb=0:2:20 and and i want to do that for N=1000 packages .Gn Gnkhttps://fr.mathworks.com/matlabcentral/profile/authors/16544080-gn-gnktag:fr.mathworks.com,2005:Question/4865442019-10-21T10:48:40Z2019-10-21T13:38:56ZCoherence as a function of time Hey,
How is it possible in MATLAB to calculate Coherence as a function of time for two nonstationary signals (EEG) as shown on the below image. I want to genereate a similar one in matlab. Can someone please help me. I am very new to matlab so a code will help.
Hinna Ahmedhttps://fr.mathworks.com/matlabcentral/profile/authors/6904558-hinna-ahmedtag:fr.mathworks.com,2005:Question/4865512019-10-21T11:13:31Z2019-10-21T13:35:35ZBattery model - using vector concatenate to collate individual cell outputsI am trying to model a battery model with 3 cells in parallel, and so want to collate all of the output data from each of the cells into a single scope. I am trying to use a vector concatenate or a mux in order for the three output signals to be collated into one single signal in order for the data to be connected to a scope. However the data I obtain from this for each of the cells is extremely high values and not in line with what it should be. To test this I attached a scope individually to each of the cells prior to the link to the concatenate and the outputs were expected for the model. There is obviously an issue associated with collating the signals so I was wondering if anyone knows of a fix for this?
Thanks Jacob Comptonhttps://fr.mathworks.com/matlabcentral/profile/authors/16175421-jacob-compton