Respondida
Excel and MATLAB connection
You can use xlsread to read data from Excel in your code. I would avoid the use of ActiveX whenever you can avoid it. You can fi...

más de 7 años hace | 1

Respondida
Average of a single element in an array
The best method depends on how you have generated your array. I will show two examples below. %example 1: only integers A=rand...

más de 7 años hace | 1

| aceptada

Respondida
How can I rotate the lines on an image
You can use code similar to that below. I changed the step size to 30 degrees to make it more clear what is happening. clc cen...

más de 7 años hace | 0

| aceptada

Respondida
how to sum of each row according to values values in given function
You can do something like the code below. You could use a for loop instead of the call to cellfun, but as you can see, you don't...

más de 7 años hace | 2

| aceptada

Respondida
how to estimate bright channel for color image in Matlab??
Below you find 2.5 strategies. The first should be a lot faster, especially for larger images. With the last it is easier to see...

más de 7 años hace | 0

Respondida
Please advise me on how to improve the efficiency of this code?
You could use an explicit dialog box to avoid any confusion: answer = questdlg(... 'Do you want to try again?', ...%questi...

más de 7 años hace | 0

| aceptada

Respondida
Working with dicom images
You need to convert to either a double or a int16 (before applying the subtraction). The latter only has a maximum half as high ...

más de 7 años hace | 0

| aceptada

Respondida
Using a While loop to determine number greater than a constant
I'm a bit hesitant to provide you with a complete working solution, since you mention it is homework. I will give you some advic...

más de 7 años hace | 0

Respondida
Why reading in csv files will not work for me.
Why aren't you trying something like this? files = dir('*.csv') Q = numel(files); data=cell(Q,1); for n=1:Q % Read in C...

más de 7 años hace | 0

Respondida
distributing two values in 3d array
You could also do the following: L=60; % Number of columns b=25; % Number of rows w=25; %the depth of the 3D lattice K_f1=5e...

más de 7 años hace | 1

Respondida
make cell and put number on it
You can do it like this: n=20; result=num2cell(1:n);

más de 7 años hace | 0

| aceptada

Respondida
reducing resolution of an image
You can use the imresize function to resample images: A=uint8(randi(255,1666,1200,3));%generate random 2MP image dims=size(A);...

más de 7 años hace | 0

| aceptada

Respondida
Title a plot with variable 'char'
Your function declaration must match the use, so you need to put this line at the top of your function instead: function [figur...

más de 7 años hace | 0

| aceptada

Respondida
Update my plot each time parameters change
You should set the callback function of your slider to update the plot. If you need more specific help, attach your code (and fi...

más de 7 años hace | 0

| aceptada

Respondida
How to optimize this equation:Collection/ward ( Y) = 1.55495763465296E-06-1.57475099626936E-09*C1+ 1.23047294575684E-10*C3+ 1499.99999957807*C4
This is something you could solve algebraically: C4=(1.55495763465296E-06-1.57475099626936E-09*C1+ 1.23047294575684E-10*C3-y)/(...

más de 7 años hace | 2

Respondida
How do I find the maximum and minimum value(s) of my randomly generated bar chart, and set a specific color for the max and min value(s)?
The code below puts 2 extra bar plots with the desired colors. It also avoids loops. %n_throws=input("choose a number of throws...

más de 7 años hace | 0

| aceptada

Respondida
Is it possible to store jpg images in an array to use in a function?
To give an example of how you could do it with a cell array: images=cell(2,10); ratios=zeros(1,size(images,2)); for n=1:size(...

más de 7 años hace | 1

Respondida
code for conditional statement
You can use code similar to that below. It is easier to put the input data in a cell arrray than to have different names for the...

más de 7 años hace | 0

| aceptada

Respondida
can not plot the graph and there is samething wrong on my script, can anyone checkit
Your code doesn't do what you think it does. You could see that by looking at your variables: they have become scalars, instead ...

más de 7 años hace | 1

Respondida
"set" VS "=" assignment
The set syntax is older than the object notation. The advantages of the set syntax are that you can use it in older Matlab rele...

más de 7 años hace | 1

| aceptada

Respondida
Calculate the Area Between Two Curves
This code should help. It assumes you want to count all the area between the two lines as positive. The more crossings there are...

más de 7 años hace | 1

Respondida
Display Value in Text Box
You need to transform your value to text using either sprintf or num2str: a=trapz(cP6-cP7); str=sprintf('Area Swept: %d',a);...

más de 7 años hace | 1

| aceptada

Respondida
How do I verify user input from prompt/inputdlg and go back to same prompt if input is invalid?
One of the ways to solve this is with a recursive function. (another solution you could choose is a while loop) function matrix...

más de 7 años hace | 0

| aceptada

Respondida
How to use waitbar while copying images from folders and subfolders
What I would do is first make a list of all sources and targets, and then do the actual copying in a loop like this h_wait=wait...

más de 7 años hace | 0

| aceptada

Respondida
Link to MATLAB documentation
If you type this doc prob.normaldistribution.random at least you will get to the correct doc page. You'll have to scroll (or u...

más de 7 años hace | 0

| aceptada

Respondida
How to detect first 50 white pixels from right side of a binary image?
You can use find to get the indices from the left, so the only thing you need to do is flipping the image and convert the col in...

más de 7 años hace | 0

| aceptada

Respondida
Display figure returned by .m function into GUI axis
(This is an earlier comment reposted as answer. I would suggest giving Jan's answer an upvote if you think he helped to get to a...

más de 7 años hace | 0

| aceptada

Respondida
Facing a problem in calculating the sum of digits of 100!.
This is due to how computers store digits. You will need to rethink your method for big numbers: clc %don't use clear, use fun...

más de 7 años hace | 0

Respondida
Exclude one row from calculation
The easiest way to do this is with a logical vector: Reference=2; ABC=[1;2;3;4;5;6]; L=ABC~=Reference; logodds(1:5,:)=log(AB...

más de 7 años hace | 0

| aceptada

Respondida
Area between two curves that intersect
You are using the loop incorrectly, and you don't need it anyway. You are doing an integration over a single point, which is unl...

más de 7 años hace | 2

| aceptada

Cargar más