https://www.mathworks.com/matlabcentral/answers/questionsMATLAB Answers — New Questions2019-04-19T18:05:07Ztag:www.mathworks.com,2005:Question/4568972019-04-17T10:14:53Z2019-04-19T18:05:07ZHow to convert a cell array of structs into a table?I am trying to write a script to analyse data downloaded from Facebook messenger, such as the message count, most common times, wordcloud etc. However I keep running into an issue with accessing the data. The file I've downloaded is a JSON file that, when imported and decoded using jsondecode(), becomes a 1x1 struct with a few fields. I am only interested in the 'messages field' within it, so I extracted it to a separate variable called messages.
data=fileread('message_test.json');
data=jsondecode(data);
messages=data.messages;
Now messages is a Nx1 cell array of structs, which in turn have 4 fields each: sender_name, content, timestamp_ms and type - 3 of these are chars and one is a number. What I would like to do is convert this Nx1 cell array into a Nx4 table with headers corresponding to the struct fields. I have tried using cell2table and struct2table on it, but unsuccessfully.
A = cell2table(messages)
B = struct2table(messages{1,1})
C = struct2table(messages{2,1})
Expectedly, A returns a 21x1 table of structs which is not what I'm after. I think B and C get me somewhat closer to a solution, because they return 1x4 tables, which would give me what I need if only I could join them. However, I cannot concatenate them using neither vertcat() or the regular [B;C]:
D = [B; C]
D = vertcat(B,C)
Both give the following error:
Could not concatenate the table variable 'sender_name' using VERTCAT.
Caused by:
Error using vertcat
Dimensions of arrays being concatenated are not consistent.
I don't quite understand that error, because both B and C are 1x4 tables, so the dimensions seem compatible?
I have also considered using a loop to extract each row of the cell array as a 1x4 table and then merging them but that does not work, because apparently the chars have different lengths and cannot be joined. Could somebody please help me out? I've attached the sample file below.
Thank you in advance.Jakub Sekulahttps://www.mathworks.com/matlabcentral/profile/authors/11966053-jakub-sekulatag:www.mathworks.com,2005:Question/4574072019-04-19T17:48:37Z2019-04-19T18:02:54Zuse textread to read sparse format dataHi I have a machine learning data of this format
1.0000 1:-1.4623 2:0.6451 3:-0.8359 404:-0.7488 509:-1.0544
-1.0000 1:-0.1284 5:-0.4758 12:1.9424
so in summary, in each paragraph i, the first data is y_i, and the rest of paragraph specifies the index of x_i, and the value of x_i.
I wonder can I quickly read this kind of data to matlab .mat file with textreadMingxi Zhuhttps://www.mathworks.com/matlabcentral/profile/authors/13425886-mingxi-zhutag:www.mathworks.com,2005:Question/4559062019-04-12T02:26:39Z2019-04-19T17:59:09Zmultiple grouping octave and layersHey all, i want to ask how to grouping this data by octave (first column) and layer (second column), is there some way to do this? i thought it must be used groupcounts, i was tried, but still got an error. After grouping i must be sorted by the number. so i could know which minor of that group then proceed it first using kmeans(12) by at least 2 value every group. But if there is group that have less than 2, we skipped it.
1 1 159 92
1 1 111 43
1 1 111 64
1 1 119 56
1 1 131 113
1 2 192 121
1 2 192 104
1 2 203 63
2 2 147 84
2 2 150 73
2 2 166 31
2 2 167 70
2 2 171 70
2 2 181 32
2 2 183 80
2 2 185 85
3 1 200 18
3 1 134 63
3 2 110 31
groups would look like follows:
octave 3 and layer 2 = 1
octave 3 and layer 1 = 2
octave 1 and layer 2 = 3
octave 1 and layer 1 = 5
octave 2 and layer 2 = 8
result of kmeans must 12 point (i dont know how), so after using kmean at least like this below (number of group must be distributed)
octave 3 and layer 2 = 1
octave 3 and layer 1 = 2
octave 1 and layer 2 = 3
octave 1 and layer 1 = 3
octave 2 and layer 2 = 3
Elder Winterhttps://www.mathworks.com/matlabcentral/profile/authors/8763302-elder-wintertag:www.mathworks.com,2005:Question/4574102019-04-19T17:58:40Z2019-04-19T17:58:40ZHow can I find the frequency response of a sine wave?For example; find the frequency response of s1(t), S1(j𝜔).
where s1(t) = sin(2*pi*50*t)
and t=0:0.001:1
then whati is S1(j𝜔)?yasemin gençhttps://www.mathworks.com/matlabcentral/profile/authors/9986896-yasemin-genctag:www.mathworks.com,2005:Question/4572872019-04-19T00:11:28Z2019-04-19T17:57:47ZToo many input arguments with parfor looptrying to run this instruction
>> Iteration('Al',[100:25:175],1.33)
function Iteration(type,data,n)
tic
length1 = length(data);
switch type
case 'Al'
parfor i = 1:length1 % line:21
if exist(sprintf('%d.mat',data(i)), 'file')==0
Slambda_Al(data(i),n);
end
fprintf('%d of %d\n',i,length1);
end
I get this error if the current directory contains a ".m" file otherwise runs without errors.
Error using Iteration (line 21)
Too many input arguments.Adel Sarhanhttps://www.mathworks.com/matlabcentral/profile/authors/14955652-adel-sarhantag:www.mathworks.com,2005:Question/4574092019-04-19T17:55:06Z2019-04-19T17:55:06ZHow can I design a lowpass filter “[ss]=lowpassfilter(s,fcut,fs)” which filters input signal “s” with cutoff frequency “fcut” and sampling frequency “fs” in Hertz?I want to design a lowpass filter. “[ss]=lowpassfilter(s,fcut,fs)” which filters input signal “s” with cutoff frequency “fcut” and sampling frequency “fs” in Hertz. After this I will need to filter a sine wave with “lowpassfilter.m” function with cut-off frequency fc=100 Hz, and obtain filter output y(t).yasemin gençhttps://www.mathworks.com/matlabcentral/profile/authors/9986896-yasemin-genctag:www.mathworks.com,2005:Question/4573902019-04-19T15:03:50Z2019-04-19T17:54:58ZWhat's the difference between Matlab runtime and Matlab(R) Compiler RuntimeMy comupter installed both Matlab runtime and Matlab(R) Comiler Runtime. See following picture. What's the difference between those two softwares?
The purpose for those two softwares is to do some calculation in excel file, but some function need support from Matlab.
qingyang liuhttps://www.mathworks.com/matlabcentral/profile/authors/12480564-qingyang-liutag:www.mathworks.com,2005:Question/4574052019-04-19T17:35:57Z2019-04-19T17:54:34ZI want to curve fit an output with multiple inputs?I have a set of data that has multiple inputs with one output. I'd like to know how to get an equation that estimates my output using Matlab. Is there a tutorial or someone i can speak with to know if the product does this before purchasing.Robert Fudahttps://www.mathworks.com/matlabcentral/profile/authors/15291270-robert-fudatag:www.mathworks.com,2005:Question/32062011-03-15T00:15:41Z2019-04-19T17:52:09ZHelp with Statistics Toolbox: Output argument "err" (and maybe others) not assigned during call to "C:...filepath...\statsizechk.m>statsizechI am using Matlab 7.11.0 (R2010b) Windows 32 bit with the statistics toolbox installed. I recieve this error when I use the pearsrnd function.
Error in ==> pearsrnd at 69
[err, sizeOut] = statsizechk(4,mu,sigma,skew,kurt,varargin{:});
??? Output argument "err" (and maybe others) not assigned during call to
"C:\...filepath...\statsizechk.m>statsizechk".
While searching the web I found that others have recieved this error using different functions, but I have not found a solution.
Could I have the wrong toolbox version for my matlab release?
thanks,
susanSusanhttps://www.mathworks.com/matlabcentral/profile/authors/2325639-susantag:www.mathworks.com,2005:Question/4542272019-04-03T18:03:55Z2019-04-19T17:44:24ZRMSE of sequences in cell arrays with different lengthIn the Sequence-to-Sequence Regression Using Deep Learning example the rmse is caclulated this way
for i = 1:numel(YTest)
YTestLast(i) = YTest{i}(end);
YPredLast(i) = YPred{i}(end);
end
figure
rmse = sqrt(mean((YPredLast - YTestLast).^2))
in this case we are interested only on the last element so YPredLast - YTestLast is one to one element substraction
IN the general case that i am interested on the whole output sequence, what will be the substraction??
YTest - Ypred cannot be performed as these are cell arrays.
how can we calculate the rmse from the whole sequencies?sotiraw sotiroglouhttps://www.mathworks.com/matlabcentral/profile/authors/11712185-sotiraw-sotirogloutag:www.mathworks.com,2005:Question/4573942019-04-19T15:44:25Z2019-04-19T17:42:15ZHow can I solve the equation of type h ? 6 unknows 6 equationsHello.
I would like to find out the result of the equation I mentioned below, type 'h'. For example A = 5h B = 0.65h C=.... How can I define the h. And I want to soln type h. Please answer immediately.
function fourthordereqn()
%We need solve the system forward mesh points.
%System want to solve y''(0)
%We must use 4+2=6 forward mesh points.
'f2(0)=A*f(0)+B*f(1)+C*f(2)+D*f(3)+E*f(4)+F*f(5)';
'Z0=A*f(0)';
'Z1=B*(f(0)+h*f1(0)+(h^2)/2*f2(0)+(h^3)/6*f3(0)+(h^4)/24*f4(0)+(h^5)/120*f5(0)+O*(h^6))';
'Z2=C*(f(0)+2*h*f1(0)+2*h^2*f2(0)+(2^3*h^3)/6*f3(0)+(2^4*h^4)/(4*3*2)*f4(0)+(2^5*h^5)/(5*4*3*2)*f5(0)+O*(h^6))';
'Z3=D*(f(0)+3*h*f1(0)+(3^2*h^2)/2*f2(0)+(3^3*h^3)/6*f3(0)+(3^4*h^4)/(4*3*2)*f4(0)+(3^5*h^5)/(5*4*3*2)*f5(0)+O*(h^6))';
'Z4=E*(f(0)+4*h*f1(0)+(4^2*h^2)/2*f2(0)+(4^3*h^3)/6*f3(0)+(4^4*h^4)/(4*3*2)*f4(0)+(4^5*h^5)/(5*4*3*2)*f5(0)+O*(h^6))';
'Z5=F*(f(0)+5*h*f1(0)+(5^2*h^2)/2*f2(0)+(5^3*h^3)/6*f3(0)+(5^4*h^4)/(4*3*2)*f4(0)+(5^5*h^5)/(5*4*3*2)*f5(0)+O*(h^6))';
'f(0)=0; f1(0)=0; f2(0)=1; f3(0)=0; f4(0)=0; f5(0)=0';
syms A B C D E F
%Write the equations for
%1st eqn f(0)=0
equation1=A+B+C+D+E+F;
%2nd eqn f1(0)=0
equation2=B*h+C*2*h+D*3*h+E*4*h+F*5*h;
%3rd eqn f2(0)=1
equation3=-1+(B*h^2/2)+(C*2*h^2)+(D*3^2*h^2/2)+(E*4^2*h^2/2)+(F*5^2*h^2/2);
%4th eqn f3(0)=0
equation4=(B*h^3/6)+(C*2^3*h^3/6)+(D*(3^3*h^3)/6)+(E*4^3*h^3/6)+(F*5^3*h^3/6);
%5th eqn f4(0)=0
equation5=(B*h^4/24)+(C*2^4*h^4/24)+(D*3^4*h^4/24)+(E*(4^4*h^4)/(4*3*2))+(F*(5^4*h^4)/(4*3*2));
%6th eqn f5(0)=0
equation6=(B*(h^5)/120)+(C*(2^5*h^5)/(5*4*3*2))+(D*(3^5*h^5)/(5*4*3*2))+(E*(4^5*h^5)/(5*4*3*2))+(F*(5^5*h^5)/(5*4*3*2));
sol.a=solve(equation1,equation2,equation3,equation4,equation5,equation6);
SOLN = structfun(@double,sol.a);
disp(SOLN);
but I'm having this problem.
Undefined function or variable 'h'Onur Ozturkhttps://www.mathworks.com/matlabcentral/profile/authors/15326165-onur-ozturktag:www.mathworks.com,2005:Question/492862012-09-27T21:29:03Z2019-04-19T17:41:38Zgenerate n numbers of static text boxes in a guihow do i generate n numbers of static text boxes automatically? i.e. i dont have to go through guide in manually selecting each textbox.. coz here n is very large, in orders of 500s.. or is there any other text box type option available which can be generate automatically through a loop?Shree Nathhttps://www.mathworks.com/matlabcentral/profile/authors/3425803-shree-nathtag:www.mathworks.com,2005:Question/4573952019-04-19T15:50:48Z2019-04-19T17:38:56Zintegral of symbolic functionHey everybody,
I tried to integrate following equation with symbolic functions (i.e):
syms x(t) y(t)
f=sin(x)^2*diff(y,t)
F=int(f)
but matlab response only with the same equation and a integration sign in front of it.
Can somebody help me, how to show the right Integral of it without integral sign?
Thank you. Meik Seedorfhttps://www.mathworks.com/matlabcentral/profile/authors/13276895-meik-seedorftag:www.mathworks.com,2005:Question/4574062019-04-19T17:37:22Z2019-04-19T17:38:31ZBasic Looping help pleaseadj = zeros(250,2);
for i = 1:12;
idx1 = whole_yeast == four(i,2);
idx2 = idx1(:,2)
out1 = whole_yeast(idx2)
end
adj
I am trying to map the network. The node '4' is the center and I want to map out the connections to 3rd order node.
'four' is what node 4 connects to (there are 12 of them)
'out1' is third order nodes from what each of the second order node connect to
'whole_yeast' is the edgelist of the wholenetwork
The problem is that I want to put the number of node infront of each 'out1' and make adjacency matrix of second node that are connect to third node. I am wondering if that needs double loop and how to do it? Thank you very much.
If you do not understand what I wrote , the textfile is the data and I want to get how to obtain the edgelist from node '4' to second order node and second order node to third order node so that I could map out the connection of the network. Thank you again (I spent hours trying and still could not get it; please help this poor non-computer major college kid)
Tuntanut Lohawatcharagulhttps://www.mathworks.com/matlabcentral/profile/authors/14523282-tuntanut-lohawatcharagultag:www.mathworks.com,2005:Question/4574042019-04-19T17:31:19Z2019-04-19T17:31:19ZWarning: Length of upper bounds is > length(x); ignoring extra bounds. %Loading the train data
load 'train.mat'
xtrain = train_data;
ytrain = train_label;
tr_s_one = size(xtrain,1);
tr_s_two = size(xtrain,2);
tr_lab = size(ytrain,1);
%Loading the test data
load 'test.mat'
xtest = test_data;
ytest = test_label;
te_s_one = size(xtest,2);
te_lab = size(ytest,1);
%Checking if the files exist
if exist('train.mat', 'file') == 0 && exist('test.mat', 'file')
error(['Error: File eval.mat are not available.']);
else
disp('train.mat and test.mat files found');
end
maximum = max(xtrain,[],2);
minimum = min(xtrain,[],2);
%Preprocessing & normalizing the train data
%Xnorm = (X - min(X)) ./ (max(X) - min(X))
tr_norm = (xtrain-minimum*ones(1,tr_s_two))./((maximum - minimum)*ones(1,tr_s_two));
%Preprocessing & normalizing the test data
te_norm = (xtest-minimum*ones(1,te_s_one))./((maximum - minimum)*ones(1,te_s_one));
%% Soft Margin SVM with Polynomial Kernel
%Quadratic Programming
C = [0.1 0.6 1.1 2.1];
for p=2:5
for j=1:length(C)
kernel = (ones(size(tr_norm,2),size(tr_norm,2)) + (tr_norm'*tr_norm)).^p;
%Checking Mercer's condition
merc = eig(kernel);
merc(abs(eig(kernel))<1e-4) = 0;
if size(merc(merc<0),1) ~= 0
disp('Mercer''s condition not met.');
return
end
H = (ytrain*ytrain').*kernel;
f = -ones(tr_lab,1);
A = -eye(tr_lab);
b = zeros(tr_lab,1);
Aeq = ytrain';
beq = 0;
lb = zeros(tr_lab,1);
ub = C.*ones(tr_lab,1);
x0 = [];
options = optimset('LargeScale','off','MaxIter',1000,'TolX',1e-10);
alpha = quadprog(H,f,A,b,Aeq,beq,lb,ub,x0,options);
a_d = kernel*(alpha.*ytrain);
thr = 1e-4;
SV = find(alpha>thr);
b = ytrain(SV)-a_d(SV);
b0 = mean(b);
b0_tr = b0*ones(size(tr_norm,2),1);
b0_te = b0*ones(size(te_norm,2),1);
%Discriminant function
g_train = ((tr_norm'*tr_norm) + ones(size(tr_norm'*tr_norm))).^p*(alpha.*ytrain) + b0_tr;
g_test = (te_norm'*tr_norm + ones(size(te_norm'*tr_norm))).^p*(alpha.*ytrain) + b0_te;
%Train Accuracy
g_train(g_train>=0) = 1;
g_train(g_train<0) = -1;
train_error = ytrain - g_train;
disp('Training Accuracy with Hard Margin SVM (Polynomial Kernel):');
disp(strcat('p is: ',num2str(p)));
disp(100*size(train_error(train_error==0),1)/tr_lab);
%Test Accuracy
g_test(g_test>=0) = 1;
g_test(g_test<=0) = -1;
test_error = ytest - g_test;
disp('Test Accuracy with Hard Margin SVM (Polynomial Kernel):');
disp(strcat('p is: ',num2str(p)));
disp(100*size(test_error(test_error==0),1)/te_lab);
end
end
After i run the program i get a warning that says:
Warning: Length of upper bounds is > length(x); ignoring extra bounds.
> In checkbounds (line 41)
In quadprog (line 297)
In Untitled15 (line 61)
Can i know why this warning occurs?Gautami Golanihttps://www.mathworks.com/matlabcentral/profile/authors/14615476-gautami-golanitag:www.mathworks.com,2005:Question/4563082019-04-14T18:51:56Z2019-04-19T17:18:50ZHow to split the string with Mathematical operators?I have equations:
a = '(Id_M5)/Cc'
b =' (VDD-VSS)*(Id_M5+(2*(Id_M7)))'
How to split these?
I want answers like:
a = [Id_M5 Cc]
b = [VDD VSS Id_M5 2 Id_M7]
Harsha M Vhttps://www.mathworks.com/matlabcentral/profile/authors/8626163-harsha-m-vtag:www.mathworks.com,2005:Question/4553992019-04-09T21:55:49Z2019-04-19T17:14:08ZHow to save in n different variables string data separated by commaHi everybody.
I need help please. Anyone know how can I save string number composed by 2 columns and n rows in 2 different variables?. For example in the first iteration, the string is like the following:
RX='0.036,0.029'
I expect the algorithm divide the string until the comma then create the variables A and B with the coefficients data:
A=0.036
B=0.029
ThanksJuan Jose Ortiz Torreshttps://www.mathworks.com/matlabcentral/profile/authors/13365002-juan-jose-ortiz-torrestag:www.mathworks.com,2005:Question/1442802014-07-31T21:35:53Z2019-04-19T17:05:58ZHow can I import data from .xls using for Principal Component Analysis (PCA)?Hello,
I have a worksheet in excel that contains the following data:
17 rows x 5 columns of data - the first row contains the title 3 of the variables (names of 3 different people), meanwhile column 1 contains the title for the 16 different possibilities. the internal matrix, which ends up being a 16x4, contains the statistic. I import the data into Matlab, but don't know if i should import as a matrix, cell array, or dataset. From there, how do I perform PCA? I want it to contain the names of the variables.
So far, I've performed this:
>> coeff = princomp(Cocktail1)
coeff =
0.0453 0.9976 0.0500 -0.0130
0.4413 -0.0662 0.8831 -0.1453
0.5300 -0.0067 -0.1275 0.8383
0.7227 -0.0172 -0.4489 -0.5253
However, the problem is it does not show me titles of the variables.
Thank you.
Michellehttps://www.mathworks.com/matlabcentral/profile/authors/5474779-michelletag:www.mathworks.com,2005:Question/4574012019-04-19T16:59:36Z2019-04-19T17:01:26ZHow do I put a series of sum into a function?Hi! I am trying to solve the optimization problem for a risk parity portfolio. To be precise:
is a nx1 vector of portfolio weigths and th nxn covariance matrix.
The variable port_size is a scalar that returns the number of assets invested in.
I tried to solve it with fmincon, but the first problem that is appearing is that apparently I cannot do the fun_rp = @(w_rp) with the for loop as MATLAB gives me the error: illegal use of reserved keyword "for".
w_mv0 = [0.25; 0.25; 0.25; 0.25];
Aeq = ones(1, port_size);
beq = 1;
lb = zeros(1, port_size);
ub = ones(1, port_size);
fun_rp = @(w_rp) for i = 1:port_size
for j = 1: port_size
(w(1,i)*(C*w(1,i)')-w(1,j)*(C*w(1,j)'))^2;
end
end
w_rp = fmincon(fun_rp,w_rp0,[],[],Aeq,beq,lb,ub)
Does anybody know where my mistake is? I´d appriciate every help!
Best regardsDennis Göbelhttps://www.mathworks.com/matlabcentral/profile/authors/15303690-dennis-gobeltag:www.mathworks.com,2005:Question/4574022019-04-19T16:59:52Z2019-04-19T16:59:52ZPaint on Image GUIHey guys,
Basically, I have a matrix filled with 0's and 1's that is a representation of an image. I essentially want a GUI that allows me to see the picture and click on points I want to be 1's. I know I can look at the image, write down the points that I want to fill, and then manually alter the matrix, but that's a lot of work/would take longer/is tedious.
Thanks for all your help.John Shackletonhttps://www.mathworks.com/matlabcentral/profile/authors/14657992-john-shackletontag:www.mathworks.com,2005:Question/112822011-07-10T22:44:46Z2019-04-19T16:59:49ZHow to implement an ACO algorithm for vehicle routing?I am currently studying different methods to solve VRP and was wondering whether there are any pre-written codes to implement possible solution techniques available? Considering ACO, Tabu Search and Genetic Algorithms. Thanks.Roxannehttps://www.mathworks.com/matlabcentral/profile/authors/2926461-roxannetag:www.mathworks.com,2005:Question/4574002019-04-19T16:54:24Z2019-04-19T16:58:48ZSerious mistake installing MatlabI wasn't paying attention and accidentally installed Matlab in c:\ which appears to be a big problem and the windows installer doesn't recognize the installation. How do I uninstall and reinstall Matlab? (i.e., no MATLAB\version, but rather C:\bin, etc.
Process is complicated as I need to work with IT to run as admin.Curtis DeGasperihttps://www.mathworks.com/matlabcentral/profile/authors/1924306-curtis-degasperitag:www.mathworks.com,2005:Question/4573992019-04-19T16:51:10Z2019-04-19T16:58:13ZHow to make result of features more rapidly in interface GUIhello, I am a beginner in matlab, I made an interface for the diagnosis of cancer, I made 4 buttons ( download image, preprocessing, segmentation, extraction features) depend on each other, each function that comes after I copy the code of the function how is previous and command of new function for that my interface is more slowlyNaja Najahhttps://www.mathworks.com/matlabcentral/profile/authors/15093155-naja-najahtag:www.mathworks.com,2005:Question/3465062017-06-27T21:18:57Z2019-04-19T16:56:38ZControlling an SCPI instrument in SimulinkHi all,
I’m working on interfacing a dSPACE-based controller with a power supply that speaks SCPI, and I’m trying to figure out how to use their Ethernet blockset to do it, which is much like Mathworks' TCP/IP Send and TCP/IP Receive blocks. Because of how compiled Simulink models interact with their Ethernet hardware and drivers, I cannot use the Instrument Control Toolbox.
An example query would be “volt:prot?\r\n” to query the overvoltage threshold, and “volt:prot 50\r\n” to set it. The query would receive a reply something like “50\r\n”, and the command would receive no reply at all.
I can compose outbound messages easily enough with array concatenation, but I’m at a loss as to how to parse variably-sized incoming replies, or to accumulate incoming bytes until a reply has completely come across the wire. For example, a command of “<> STA?\r\n” requests a status, and gets a reply like “, 1, 2, 3, 4\r\n”. If I requested a buffer of 100 bytes, I’d have to send the command several times, and I’d get a number of replies glued together; if I requested a buffer of 1 byte, I wouldn’t know what to do with it until I got the “\r\n” pattern. I could write a stream-oriented parser for incoming messages, but that wouldn’t know, for a reply of ‘1000’, if the first ‘1’ should be multiplied against 1, 10, 100, or 1000, so that’s not a great solution.
Pure-Simulink solutions are ideal, since I need to generate code from this model, but I may be able to modify function blocks to do what's needed - the restrictions of the environment and toolchain make it dicey.
Thanks in advance!chris akinshttps://www.mathworks.com/matlabcentral/profile/authors/10468617-chris-akinstag:www.mathworks.com,2005:Question/4573972019-04-19T16:39:38Z2019-04-19T16:54:56ZHow can I generate reciprocal of a matrixI have big matrix A 500 by 500 and I want to generate reciprocal of matrix A
what caluclation shuould I do or is there a function in matlab that I can use
%Matrix A
A = [2, 3, -1, 5; -1, 4, -7, -3; -6, 0, 3, 9; 7, 6, -3, 8];
%Matrix X, reciprocal of matrix A
X= ....
will99https://www.mathworks.com/matlabcentral/profile/authors/7072125-will99tag:www.mathworks.com,2005:Question/4573642019-04-19T12:18:32Z2019-04-19T16:52:34ZTemperature-sensitive transport modelHello,
For an assignment I am looking for some help / guidance towards the right tutorials or model.
I have a batch of data of temperature-sensitive goods that are exposed to ambient temperature. For several steps in the chain (lets say 3 transport steps + 2 queue moments inbetween those steps), I want to show how the temperature of the good is influenced by the ambient temperature.
My data:
time t1
time t2
ambient temperature on t1 and t2 (and inbetween)
temperature_min and temperature_max that the goods should be
I have this data for a whole year and for all transport and queue steps
My goal:
Have a model in which I can enter the above mentioned parameters
Output: graphs that show if the ambient temperature is in between the min/max of the good (and so is not affective)
My ultimate goal is to have a model that shows how the temperature of the good differs from the starting point in the current state and, with the implementation of a solution like a thermal cover or a blanket, this difference can be reduced.
I'm still in need of some thermal equations to show how the temperature of the good differs from the starting point, thinking about the mean kinetic temperature or degree-hour KPI at the moment.
Any tips or tricks are more than welcome. johanderksen123https://www.mathworks.com/matlabcentral/profile/authors/3060546-johanderksen123tag:www.mathworks.com,2005:Question/4573092019-04-19T03:33:40Z2019-04-19T16:51:30Zcould anyone help me to solve the issue in the following code.code:
clear all;
clc;
X=[ 9 10 11 ;
5 6 7 ;
4 3 2 ]
Y=[0.1 0 0.2 ;
0 0.3 0 ;
0 0.5 0 ]
A = partitions(3);
total_number_of_partitions = length(A);
for particle=1
idx = randperm(total_number_of_partitions,1) ;
particle = A(idx);
partdisp(particle);
for len_partition=1:length(particle)
for len_cluster=1:length(particle{len_partition})
display_user_inside_cluster=(particle{len_partition}{len_cluster})
for x =1:size(X,2)
for y =1:size(Y,1)
throughput(x,y) =1+((X(x,y)).*(Y(x,y)));
end
end
overall_throughput = sum(sum(throughput));
end
end
end
totalthroughput=sum(overall_throughput)
I run the above code and got the result as follows:
The formation of clusters {1 2 3}:
{1} {2} {3}
As there are three clusters i am getting three values of overall_throughput each one corresponds to one cluster using the command line
overall_throughput = sum(sum(throughput));
In next step I need to add all the three overall_throughput together.
So i used the command line
totalthroughput=sum(overall_throughput).
But it doesnot add all the three overall_throughput together.
Could anyone help me how to add all three overall_throughput together.jaah navihttps://www.mathworks.com/matlabcentral/profile/authors/11695462-jaah-navitag:www.mathworks.com,2005:Question/4573982019-04-19T16:42:09Z2019-04-19T16:42:09ZHelp with nested structureHello,
I use Matlab for my data analysis. I did a script in which, as output, I obtain a nested structure organized by sublevels. Now I would like to access all my files and analyse them by groups.
So to say.... I would like to select only some of them and extrapolate some parameters from them, then I would like to do this for a different group of them and so on...
I have a structure array like this:
For example, I would like to calculate the mean of each column of the field Currents for all the levels "file_...." that have in the field "FolderLev_3" the value pH8 or things like this...
Is there an easy way to do it?
Thank you very much,
ManuelManuel Arcangelettihttps://www.mathworks.com/matlabcentral/profile/authors/10449686-manuel-arcangelettitag:www.mathworks.com,2005:Question/4573932019-04-19T15:27:07Z2019-04-19T16:41:19ZHow can print out the below content by MATLAB program?Hi,
i want to use the MATLAB to print out the below result, but I could not put the values in each row, how can I revise my program?
Thanks!
What I want to print out：
1
21
321
4321
54321
And there are my code & result：
for i = 1:1:5
for j =i:-1:1
disp(j);
end
end
1
2
1
3
2
1
4
3
2
1
5
4
3
2
1
Chao-Zhen Liuhttps://www.mathworks.com/matlabcentral/profile/authors/12138306-chao-zhen-liutag:www.mathworks.com,2005:Question/3464912017-06-27T18:47:17Z2019-04-19T16:37:26ZUse of sendmail function to send an email from a gmail accountI am trying to send an email, using the MATLAB sendmail function. I have been following the instructions of the sendmail function analysis in Mathworks on this link: https://uk.mathworks.com/help/matlab/import_export/sending-email.html
The code which I used on the command window is the following:
setpref ('Internet','E_mail','myemailaddress@gmail.com');
setpref ('Internet','SMTP_Server','smtp.gmail.com') ;
setpref('Internet',SMTP_Username','myusername');
setpref('Internet','SMTP_Password','mypassword') ;
sendmail('emailofreceiver@gmail.com','texttobesent') ;
The message that I am getting after running those commands is the following:
Error using sendmail (line 169)
530 5.7.0 Must issue a STARTTLS command first. i67sm1310611wri.61 -
gsmtp
From what I understand, I must change the arguments inside one of the setpref functions that I call, though I am not sure what exactly to include in them. Any help would be very much appreciated! Thank you in advance!ZACHARIAS KOUNTOUPIShttps://www.mathworks.com/matlabcentral/profile/authors/10466922-zacharias-kountoupistag:www.mathworks.com,2005:Question/4573632019-04-19T12:13:31Z2019-04-19T16:24:04ZWhy doe the data extracted from excel sheet gets converted to scientific power ?Hi
I am extracting a huge data from .csv file. I have to plot the time and the power data/radiation data from this file. I first convert the data into arrays and use plot function. The data is fine if I call it in small numbers but if I call the complete data, it gets converted to scientific power form. Hence, the plot is not correct. Following is the code and attached is the csv file and plots.
data = readtable('rundata2.csv');
AccColumn = {'Ppv','tload'}
Ppv = data(:,AccColumn(1));
tload = data(:,AccColumn(2));
Ppv2 = table2array(Ppv);
tload2 = table2array(tload);
plot(tload2,Ppv2)
Solution:
Ppv2(1:100)
ans =
116.5341
110.1099
... so on
But when a larger data is called
1e-16[0.0003
0.0003
0.0003
0.0003
0.0003
0.0003
... soon]Sneha Thakurhttps://www.mathworks.com/matlabcentral/profile/authors/8726314-sneha-thakurtag:www.mathworks.com,2005:Question/4573142019-04-19T04:43:11Z2019-04-19T16:13:32ZHow does Matrix(3002:2001:1999998)=0.4 works?I have a matrix with size of 1000*2000,
There is a line about : A(3002,2001,1999998) = 0.4 and the output looks like this
Can anyone help me to understand how this works?
Thanks in advanceWEI MAhttps://www.mathworks.com/matlabcentral/profile/authors/10795592-wei-matag:www.mathworks.com,2005:Question/4572762019-04-18T23:07:45Z2019-04-19T16:06:06Zhow to convert array to double i had made extract to image feature to compare by a snapshot by a webcam but i cant make if statement for this array
660×1 SURFPoints array with properties:
Scale: [660×1 single]
SignOfLaplacian: [660×1 int8]
Orientation: [660×1 single]
Location: [660×2 single]
Metric: [660×1 single]
Count: 660
so i can make if there subtraction = to zero make the if statement else do other statement saeed ahmedhttps://www.mathworks.com/matlabcentral/profile/authors/14859849-saeed-ahmedtag:www.mathworks.com,2005:Question/4573912019-04-19T15:08:34Z2019-04-19T16:01:00ZHow do I do this question using a matlab code?Matlab Userhttps://www.mathworks.com/matlabcentral/profile/authors/14655220-matlab-usertag:www.mathworks.com,2005:Question/3575902017-09-20T15:43:12Z2019-04-19T15:59:36ZFind if lines intersectI have a matrix containing data for points on a vector v = [x;y]. let's say:
%
M = [v1_x1 v1_x2 v1_y1 v1_y2; v2_x1 v2_x2 v2_y1 v2_y2; v3_x1 v3_x2 v3_y1 v3_y2]
Where v1_x1 and v1_y1 are points of a the vector v1.
v1_x2 and v1_y2 are the coördinates of the other point of the vector v1.
For every vector there are two points known.
Now I want to find if any of those vectors intersect.
there is an intersection point when:
det(v1-v3,v2-v3)*det(v1-v4,v2-v4) < 0
or
det(v3-v1,v4-v1)*det(v3-v2,v4-v2) < 0
Where v1 = [x1;y1]
How can I implement this in a code
Joaniehttps://www.mathworks.com/matlabcentral/profile/authors/5310938-joanietag:www.mathworks.com,2005:Question/4573962019-04-19T15:56:16Z2019-04-19T15:56:16Zrunning parallel loop until a variable or eventHi guys, I'm trying to make a button blink every time just when a varriable or event change:
function blink(hObject, eventdata, parent_GUI)
handles = guidata(parent_GUI);
parfor i=1:3
if get(handles.boton_circulo_visible_in,'Value')==0
i=i-1;
end
set(handles.CONECTAR,'ForegroundColor',[1,1,1]);
disp('prendido')
pause(0.5)
set(handles.CONECTAR,'ForegroundColor',[0,0,0]);
disp('apagado')
pause(0.5)
end
I tried with parfor loop but it say show me an error " changing the loop index is invalid inside a parfor loop iteration". So i loop up abaout other parallel loop like spmd, but also it executes only single time. I dont know what can i do to make that iterative until a variable change
ThanksJuan Jose Ortiz Torreshttps://www.mathworks.com/matlabcentral/profile/authors/13365002-juan-jose-ortiz-torrestag:www.mathworks.com,2005:Question/4572642019-04-18T20:57:50Z2019-04-19T15:52:19Z2 degrees of freedom mass-spring systemHi, I tried to code a script and a function in order to resolve a system composed by two masses and two springs of different values, but I had some troubles in writing the function that resolves the equations of motion.
m1=1; %mass 1 [kg]
m2=2; %mass 2 [kg]
k1=100; %spring 1 [N/m]
k2=150; %spring 2 [N/m]
M=[m1 0;0 m2]; %mass matrix
K=[k1+k2 -k2; -k2 k2]; %stiffness matrix
%% Solving system
tRange=[0 20];
x0=[0.3 0.1 1 4] ;
odefun=@(t,y) solve_sys_2nd_order(t,y,M,K);
[tsol,ysol]=ode45(odefun,tRange,x0);
%%Plot of the response
subplot(2,1,1)
plot(tsol,ysol(:,1),'b');
xlabel('tempo [s]');
ylabel('spostamento [m]');
subplot(2,1,2)
plot(tsol,ysol(:,2),'r')
xlabel('tempo [s]');
ylabel('velocità [m/s]');
The function I wrote is given by
function dy=solve_sys_2nd_order(t,y,m1,m2,k1,k2)
dy=zeros(4,1);
dy(1)=y(3);
dy(2)=y(4);
dy=[y(2);y(4);dy(3);-inv(M)*K*y];
But when I run the code, an error appears saying:
Error using *
Incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix matches the number of
rows in the second matrix. To perform elementwise multiplication, use '.*'.
Error in solve_sys_2nd_order (line 8)
dy=[y(2);y(4);dy(3);-inv(M)*K*y];
Error in two_dof_system>@(t,y)solve_sys_2nd_order(t,y,M,K)
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in two_dof_system (line 24)
[tsol,ysol]=ode45(odefun,tRange,x0);
Can anyone help me please?
federico gottardihttps://www.mathworks.com/matlabcentral/profile/authors/9815351-federico-gottarditag:www.mathworks.com,2005:Question/3592182017-10-01T16:12:23Z2019-04-19T15:48:31ZApplying hamming window and pre-emphasis filter on speech signal in frame by frame analyzingI am working on speech signals.I want to add hamming window and pre-emphasis filter on my speech signal. Here What I built.
[ip] = audioread('D:\chant_1.wav');
fs=44100;
t=(0:length(ip)-1)/fs;
plot(t,ip);
frame_duration=0.01;
N=length(ip);
frame_length=frame_duration*fs;
dir =['D:\Simulation_data\'];
cd(dir)
for k=1:num_frames
frame=ip((k-1)*frame_length+ 1 : frame_length*k);
%Window the speech segment using a Hamming window.
xi = frame.*hamming(length(frame))
%Get linear prediction filer
ncoeff=2+fs/1000;
eq=lpc(frame,ncoeff);
[h,f]=freqz(1,eq,512,fs);
r=roots(eq);
r=r(imag(r)>0.01);
ffreq=sort(atan2(imag(r),real(r))*fs/(2*pi));
length(ffreq);
fid = fopen('f5 chant.dat','at');
for j=6
fprintf(fid,'%6.8f\n',ffreq(j)) ;
end
fclose(fid) ;
end
Thank you
chamee Gunawardenehttps://www.mathworks.com/matlabcentral/profile/authors/6617176-chamee-gunawardenetag:www.mathworks.com,2005:Question/4573762019-04-19T13:33:50Z2019-04-19T15:45:34ZHow can I extract values from a histogram (figure)?Hi everyone,
Since I am very new to MatLab and will be needing it for my analysis in the coming days, I was hoping that someone could help me out.
I have a histogram (figure format), but I don't know how to extract the y-values (probability) of each bar and put it either into a list / excel file.
Could someone help me out here?
Thank you!Ola Zurekhttps://www.mathworks.com/matlabcentral/profile/authors/15281884-ola-zurektag:www.mathworks.com,2005:Question/4569222019-04-17T12:33:53Z2019-04-19T15:24:28Zturning legend off in xline functionHow can I turn off legend of xline function being visible on the plot?Manisha RANJANhttps://www.mathworks.com/matlabcentral/profile/authors/3328388-manisha-ranjantag:www.mathworks.com,2005:Question/4573892019-04-19T14:49:02Z2019-04-19T15:23:27ZFailure in initial objective function evaluation. FSOLVE cannot continue.Right after the second while loop in the code below, I am calling fsolve on a function that solves for 5 unknowns. I keep getting the error "Failure in initial objective function evaluation. FSOLVE cannot continue." I have looked at several other posts with this issue, but wasn't able to figure out what is wrong with my code. I also have another code that is very similar to this one and works just fine.
p1 = 0.01; %atm (pressure @ 1)
T1 = 200; %K (temp @ 1)
u1 = 500; %m/s (speed @ 1)
n_N2 = 0.79; %mols
n_O2 = 0.21; %mols
M_N2 = 28.014; %kg/kmol
M_O2 = 31.998; %kg/kmol
M_N = 14.007; %kg/kmol
M_O = 15.999; %kg/kmol
M_NO = 30.006; %kg/kmol
R = 8.314459848; %kJ/K*kmol
rho1 = p1*(n_N2*M_N2 + n_O2*M_O2)/((n_N2 + n_O2)*R*T1);
h1 = n_N2*cp_n2(T1)*T1 + n_O2*cp_o2(T1)*T1;
rho2_g = rho1/0.1;
counter = 0;
error = 1.0;
x0 = [0.1, 0.1, 0.1, 0.1, 0.1];
while error > 0.0001 || counter <= 10000
p2 = p1 + rho1*u1^2*(1 - rho1/rho2_g);
h2 = h1 + (u1^2/2.0)*(1 - (rho1/rho2_g)^2);
T2_g = 300.00;
err = 1.0;
count = 0;
while err < 0.001 || count <=10000
X = fsolve(@(x)Xi_eflow(x, p2, T2_g), x0);
h2_g = X(1)*cp_n2(T2_g)*T2_g + X(2)*cp_o2(T2_g)*T2_g + ...
X(3)*cp_o(T2_g)*T2_g + X(4)*cp_n(T2_g)*T2_g + ...
X(5)*cp_no(T2_g)*T2_g;
err = abs(h2 - h2_g);
if err > 0.0001
T2_g = (T2 + T2_g)/2.0;
end
if count == 10000
z = count
end
end
rho2 = p2*(Xn2*M_N2 + Xo2*M_O2 + Xn*M_N + Xo*M_O + Xno*M_NO)...
/((Xn2 + Xo2 + Xn + Xo + Xno)*R*T2_g);
if error > 0.001
rho2_g = (rho2_g + rho2)/2
end
if counter == 10000
y = counter
end
end
Below is the function that fsolve is used on.
function F = Xi_eflow(x, P, T)
R = 8.314459848; %kJ/kmol*K
Xn2 = x(1);
Xo2 = x(2);
Xo = x(3);
Xn = x(4);
Xno = x(5);
Go = -1.011066E-17*T^6 + 1.816726E-13*T^5 - 1.317613E-9*T^4 + ...
4.993102E-6*T^3 - 1.081611E-2*T^2 - 53.86166*T + 248642;
Gn = -9.090730E-18*T^6 + 1.667190E-13*T^5 - 1.243770E-9*T^4 + ...
4.874266E-6*T^3 - 1.115735E-2*T^2 - 52.39920*T + 471978.9;
Gno = 2*(7.363399E-20*T^6 - 1.268925E-15*T^5 + 3.387909E-12*T^4 + ...
5.794901E-8*T^3 - 2.905865E-4*T^2 - 12.27637*T + 90286.60);
F(1) = Xn2 + Xo2 + Xo + XN + Xno - 1;
F(2) = (2*Xn2 + Xn + Xno)/(2*Xo2 + Xo + Xno) - (0.79/0.23);
F(3) = exp(-Go/(R*T)) - Xo*P^(0.5)/Xo2^(0.5);
F(4) = exp(-Gn/(R*T)) - Xn*P^(0.5)/Xn2^(0.5);
F(5) = exp(-Gno/(R*T)) - Xno^2/(Xn2*Xo2);
end
Any help is appreciated. Thank you!
Edit: Forgot to put some other functions on here.
function y = cp_n(x)
y = 9.982621E-22*x^6 - 1.872004E-17*x^5 + 1.321452E-13*x^4 - ...
3.827231E-10*x^3 + 4.821461E-7*x^2 - 2.469692E-4*x + 20.82571;
end
function y = cp_n2(x)
y = 2.693757E-20*x^6 - 4.651184E-16*x^5 + 3.103549E-12*x^4 - ...
9.831534E-9*x^3 + 1.383600E-5*x^2 - 2.998751E-3*x + 28.88362;
end
function y = cp_no(x)
y = 2.489814E-20*x^6 - 4.154027E-16*x^5 + 2.638902E-12*x^4 - ...
7.714111E-9*x^3 + 9.019032E-6*x^2 + 1.658686E-3*x + 28.56333;
end
function y = cp_o(x)
y = 1.232504E-20*x^6 - 2.139706E-16*x^5 + 1.462356E-12*x^4 - ...
4.982123E-9*x^3 + 8.915414E-6*x^2 - 7.957834E-3*x + 23.62581;
end
function y = cp_o2(x)
y = 9.818398E-22*x^6 + 1.336256E-17*x^5 - 3.741595E-13*x^4 + ...
2.662210E-9*x^3 - 8.689588E-6*x^2 + 1.570265E-2*x + 25.37744;
endAndrewhttps://www.mathworks.com/matlabcentral/profile/authors/13278861-andrewtag:www.mathworks.com,2005:Question/4566992019-04-16T12:48:40Z2019-04-19T15:21:21ZERROR message when running codeThe following command only plots the first subplot and gives the ERROR message:
Error in subplot (line 8)
subplot(3,1,1);
and this is the code below:
clear all
clc
x = 0 : pi/150 : 2*pi;
y1 = sin(x);
y2 = sin(x-0.25);
y3 = sin(x-0.5);
subplot(3,1,1);
plot(x, y1, 'r')
subplot(3,1,2);
plot(x, y2, 'g')
subplot(3,1,3);
plot(x, y3, 'b')
grid off
xlabel('Time (sec)');
ylabel('Amp (v)');
title('Signal xt');
legend('y1', 'y2', 'y3');Amr Mousahttps://www.mathworks.com/matlabcentral/profile/authors/8659506-amr-mousatag:www.mathworks.com,2005:Question/4570592019-04-18T01:30:43Z2019-04-19T15:17:00Zn Transit compartment single distribution compartment PK absorption model in simbiologyI have built a n-transit compartment with single distibutional pharmacokinetic absorption model using SimBiology. This model is based on the TRANSIT model descibed in the following publication: Savic, R.M., Jonker, D.M., Kerbusch, T. et al. J Pharmacokinet Pharmacodyn (2007) 34: 711. https://doi.org/10.1007/s10928-007-9066-0
I chose to start by loading a one compartment absorption model with Clearance parmaeterization (macro parameters) and then modified the absorption reaction equation as n transit compartment that is based on an analytical solution to determine the transit compartment number as a continuous variable (not an interger).
analytical solution for number of compartments:
Single distribution compartment ODE:
transform of ODE for numerical stability when n is large:
Attache is a report summarizing how I defined the model in simbiology.
I am not sure if I have used the wrong syntax but I am seeing negative cincentrations at the first simulated timepoints as shown by this simulation plot:
The simulation should be a gradual absorption phase in contrast to typical tlag absorption models that are in the simbiology PK model library.
Cheers,
DanDaniel Hineshttps://www.mathworks.com/matlabcentral/profile/authors/12121290-daniel-hinestag:www.mathworks.com,2005:Question/4573862019-04-19T14:40:26Z2019-04-19T15:13:39ZHow to write cell arrays in Excel?Hi everyone,
I am trying to write a cell array in Excel but I don't get any results. The code I have prepared is below:
A = randn(10,1);
for i = 1 : 10
cell_x = sprintf('%.2f%s', A(i), '**');
Table{i} = cells_x;
end
xlswrite('Results',Table,'Test','b2')
gsourophttps://www.mathworks.com/matlabcentral/profile/authors/3847942-gsouroptag:www.mathworks.com,2005:Question/1164022014-02-17T05:00:00Z2019-04-19T15:13:06ZHow do I change the MATLAB User Interface from Korean to English in R2014a and later?
I am using R2014a or later on a Korean machine. The MATLAB Desktop, Editor and other parts of the User Interface are in Korean. However, I would like to use MATLAB with the English User Interface. How do I make MATLAB show the English Desktop?
R2014a 이후 버전을 사용 중입니다. MATLAB 데스크탑, 에디터 그리고 다른 UI의 언어가 한국어이지만 영문 MATLAB UI를 사용하고 싶습니다. 영문 데스크탑 UI로 변경하는 방법을 알고 싶습니다.
MathWorks Support Teamhttps://www.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:www.mathworks.com,2005:Question/4571132019-04-18T07:42:31Z2019-04-19T15:12:46ZHow can I fill boundary by white pixel?I have boundary pixel values in mat file and image in jpg format (colour image).
I need to fill within boundary by white pixel, others by black pixel.
final output will be binary image.
I need matlab code for it.
I have attached image and boundary pixel in mat file
bamini thavarajahhttps://www.mathworks.com/matlabcentral/profile/authors/10648716-bamini-thavarajahtag:www.mathworks.com,2005:Question/4573922019-04-19T15:11:32Z2019-04-19T15:11:32ZRaspberry Pi Camera ile Motor KontrolüMerhaba
Matlab simulink ile raspberry pi arasında bağlantı kurarak camera girdisini bir pinpon topunun yakın uzaklığını algılamak ona göre motoru ileri yada geri döndürmek istiyorum. Bunun ile ilgili tecrüberenizi paylaşırsanız sevinirim.Mehmet SENhttps://www.mathworks.com/matlabcentral/profile/authors/11297957-mehmet-sentag:www.mathworks.com,2005:Question/773232013-05-29T10:55:26Z2019-04-19T15:11:10Zgray image to 8 bit planes using bit plane slicingi have written a code to find the 8 bit planes of the gray image. i saved those images which should be in binary now. but when i am reading those images it is showing its pixel values few 0 and most 255 in binary only 0's and 1's should be there and when i did this size(d) it displayed 598 931 3.
i want it to be a in a form of 2-d array matrix with only 0's and 1's
can any one tell me what is the problem occurring?
A=imread('boy.tif');
B=bitget(A,1); figure, imshow(logical(B));title('Bit plane 1');
B=bitget(A,2); figure, imshow(logical(B));title('Bit plane 2');
B=bitget(A,3); figure, imshow(logical(B));title('Bit plane 3');
B=bitget(A,4); figure, imshow(logical(B));title('Bit plane 4');
B=bitget(A,5); figure, imshow(logical(B));title('Bit plane 5');
B=bitget(A,6); figure, imshow(logical(B));title('Bit plane 6');
B=bitget(A,7); figure, imshow(logical(B));title('Bit plane 7');
B=bitget(A,8); figure, imshow(logical(B));title('Bit plane 8');
this what i used then gave names to each of them
and when i read d=imread('bp0.tif') its giving 0 and 255 (only 0 and 255) i want ones and zeros and size should be a 2-d array why does it show 598 931 3faraz.ahttps://www.mathworks.com/matlabcentral/profile/authors/4331652-faraz-atag:www.mathworks.com,2005:Question/4573782019-04-19T13:40:57Z2019-04-19T15:08:39Zcreating sine wave with variable frequencyI used this configuration to create sine wave with variable frequency , i tried changing gain , simulation time , scope's sampling time but ofcourse they all changed wave form but with same frequency
requesta depachehttps://www.mathworks.com/matlabcentral/profile/authors/15331423-requesta-depachetag:www.mathworks.com,2005:Question/4573882019-04-19T14:45:58Z2019-04-19T15:06:31ZHow do I find a and b in terms of n ?Matlab Userhttps://www.mathworks.com/matlabcentral/profile/authors/14655220-matlab-user