f



Problems with Java from Matlab

Hi All!

I wrote a couple of classes in Java.
If I start the program from console, it works fine.
The Main class is a descendant from JFrame.

If I want to create the object in Matlab, I see an empty JFrame form - 
without contents (which is a descendent of JPanel)

Does anyone have any ideas?

Thanks
Pascal

-- snip --
public class Main extends JFrame {
     protected static ODView myODView;
     protected boolean mode3D;

     /** Creates a new instance of Main */
     public Main() {
         super("Fenster");
         setSize(300,300);
         setLocation(300,300);
         //setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
         setVisible(true);
     }

     /**
      * @param args the command line arguments
      */
     public static void main(String[] args) {
          Main g = new Main();
          myODView = new ODView2D();
          g.add(myODView);
          double myData[][] = new double[55][55];
          Random myRandom = new Random();
          for (int i=0; i<55; i++)
              for (int j=0; j<55; j++) {
                 myData[i][j] = myRandom.nextInt();
              }
          myODView.SetData(myData);
     }

     protected void Init() {
         mode3D = false;
         Set2D();
     }

     public void Set3D() {
         if (mode3D == false) {

             mode3D = true;
         }

     }

     public void Set2D() {
         if (mode3D == true) {
             myODView = new ODView2D();
             mode3D = false;
         }
     }


     public void SetData(double[][] newData) {
         myODView.SetData(newData);
     }
}
-- snap --
0
8/29/2009 2:54:12 PM
comp.soft-sys.matlab 211266 articles. 25 followers. lunamoonmoon (257) is leader. Post Follow

1 Replies
329 Views

Similar Articles

[PageSpeed] 48

Your GUI actions in main() probably need to be done asynchronously, on the EDT. This may solve a threading race-condition that may be the cause of your problem. There are plenty of examples and explanations online. Here's one snippet:

import java.awt.EventQueue;
import javax.swing.*;
 
public class B
{
  JFrame f;
 
  B()
  {
    f = new JFrame();
  }
 
  public static void main(String[] args)
  {
    EventQueue.invokeLater(new Runnable()
    {
      public void run()
      {
        B b = new B();
        b.f.setVisible(true);
      }
    });
  }
}


Yair Altman
http://UndocumentedMatlab.com 
 
0
altmanyDEL (1141)
8/29/2009 8:28:03 PM
Reply:

Similar Artilces:

problems with Java in Matlab
Hello Friends, I have Matlab R2008. Here-uin I am trying out some XML read/writes(xmlread specifically). FOr that I just pasted the code in the help files viz - xDoc = xmlread(fullfile(matlabroot, ... 'toolbox/matlab/general/info.xml')); xRoot = xDoc.getDocumentElement; Pls note that the windows I am using is the Korean version of Windows. But, I have sorted all path issues in the classpth.txt and librarypath.txt for the toolboxes and stuff. Now, when the above mentioned instructions were typed in the command window I get the following error - ??? Java exception occurred: java.io.FileNotFoundException: C:\Documents and Settings\Administrator\My Documents\MATLAB\file:\C:\Program Files\MATLAB\R2008b\toolbox\matlab\general\info.xml (?Œì¼ ?´ë¦„, ?”ë ‰?°ë¦¬ ?´ë¦„ ?ëŠ” 볼륨 ?ˆì´ë¸?구문???€ë¦½ë‹ˆ?? at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.<init>(Unknown Source) at java.io.FileInputStream.<init>(Unknown Source) at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source) at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown Source) at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source) at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source) at org.apac...

Problems calling from Matlab a Matlab compiled dll
Hi, I'm trying to make a dll from an m-file and use the dll function calling from the workspace or from an m file using 2008A version: Step 1 function [output] = addizione (a,b) output = a+b; end Step 2 I compile it with matlab compiler mcc -l addizione I obtain addizione.dll, .lib, .h etc Step 3 load the newly created addizione.dll loadlibrary ('addizione','addizione') with the following warnings: Type 'LARGE_INTEGERPtr' was not found. Defaulting to type voidPtr. Found on line 20522 of input from line 7673 of file C:\Programmi\MATLAB\R2008a\sys\lcc\include\win.h Type '_TREEITEMPtr' was not found. Defaulting to type voidPtr. Found on line 20944 of input from line 8095 of file C:\Programmi\MATLAB\R2008a\sys\lcc\include\win.h Type 'PROPSHEETPAGEPtr' was not found. Defaulting to type voidPtr. Found on line 21328 of input from line 8479 of file C:\Programmi\MATLAB\R2008a\sys\lcc\include\win.h Type '_PSPPtr' was not found. Defaulting to type voidPtr. Found on line 21329 of input from line 8480 of file C:\Programmi\MATLAB\R2008a\sys\lcc\include\win.h Type 'PROPSHEETHEADERPtr' was not found. Defaulting to type voidPtr. Found on line 21351 of input from line 8502 of file C:\Programmi\MATLAB\R2008a\sys\lcc\include\win.h Type 'LARGE_INTEGER' was not found. Defaulting to type error. Found on line 21610 of input from line 8761 of file C:\Programmi\MATLAB\R2008a\sys\lcc\include\win.h Type 'L...

Problems calling from Matlab a Matlab compiled dll #3
Hi, I'm trying to make a dll from an m-file and use the dll function calling from the workspace or from an m file using 2008A version: Step 1 function [output] = addizione (a,b) output = a+b; end Step 2 I compile it with matlab compiler mcc -l addizione I obtain addizione.dll, .lib, .h etc Step 3 load the newly created addizione.dll loadlibrary ('addizione','addizione') with the following warnings: Type 'LARGE_INTEGERPtr' was not found. Defaulting to type voidPtr. Found on line 20522 of input from line 7673 of file C:\Programmi\MATLAB\R2008a\sys\lcc\include\win.h Type '_TREEITEMPtr' was not found. Defaulting to type voidPtr. Found on line 20944 of input from line 8095 of file C:\Programmi\MATLAB\R2008a\sys\lcc\include\win.h Type 'PROPSHEETPAGEPtr' was not found. Defaulting to type voidPtr. Found on line 21328 of input from line 8479 of file C:\Programmi\MATLAB\R2008a\sys\lcc\include\win.h Type '_PSPPtr' was not found. Defaulting to type voidPtr. Found on line 21329 of input from line 8480 of file C:\Programmi\MATLAB\R2008a\sys\lcc\include\win.h Type 'PROPSHEETHEADERPtr' was not found. Defaulting to type voidPtr. Found on line 21351 of input from line 8502 of file C:\Programmi\MATLAB\R2008a\sys\lcc\include\win.h Type 'LARGE_INTEGER' was not found. Defaulting to type error. Found on line 21610 of input from line 8761 of file C:\Programmi\MATLAB\R2008a\sys\lcc\include\win.h Type 'L...

Problems calling from Matlab a Matlab compiled dll #2
Hi, I'm trying to make a dll from an m-file and use the dll function calling from the workspace or from an m file using 2008A version: Step 1 function [output] = addizione (a,b) output = a+b; end Step 2 I compile it with matlab compiler mcc -l addizione I obtain addizione.dll, .lib, .h etc Step 3 load the newly created addizione.dll loadlibrary ('addizione','addizione') with the following warnings: Type 'LARGE_INTEGERPtr' was not found. Defaulting to type voidPtr. Found on line 20522 of input from line 7673 of file C:\Programmi\MATLAB\R2008a\sys\lcc\include\win.h Type '_TREEITEMPtr' was not found. Defaulting to type voidPtr. Found on line 20944 of input from line 8095 of file C:\Programmi\MATLAB\R2008a\sys\lcc\include\win.h Type 'PROPSHEETPAGEPtr' was not found. Defaulting to type voidPtr. Found on line 21328 of input from line 8479 of file C:\Programmi\MATLAB\R2008a\sys\lcc\include\win.h Type '_PSPPtr' was not found. Defaulting to type voidPtr. Found on line 21329 of input from line 8480 of file C:\Programmi\MATLAB\R2008a\sys\lcc\include\win.h Type 'PROPSHEETHEADERPtr' was not found. Defaulting to type voidPtr. Found on line 21351 of input from line 8502 of file C:\Programmi\MATLAB\R2008a\sys\lcc\include\win.h Type 'LARGE_INTEGER' was not found. Defaulting to type error. Found on line 21610 of input from line 8761 of file C:\Programmi\MATLAB\R2008a\sys\lcc\include\win.h Type 'L...

Matlab builder JA: parse java string to matlab cell
Hi all, I'm building a java swing based GUI for my Matlab application. As such, user input is available as text strings, for example "{[0; 0], [3.5 0; 0 2]}" (mean vector and covariance matrix of a 2D Gaussian). The user input will be passed to the compiled matlab method as a MWCellArray. Problem is how do a convert (parse) the above string into a MWCellArray? From its javadoc http://www.mathworks.com/access/helpdesk/help/toolbox/javabuilder/MWArrayAPI/index.html the following method is available: java.lang.String toString() Returns a string representation of this array, but the reverse method is not. Evidently, parsing a string like the one above is a non trivial task and I'm loath to attempt writing one by myself. I would be very thankful if someone can point me to the required parser implementation. Matlab itself is carrying out this task all the time, perhaps it is possible to access Matlab's own parser. Help much appreciated, Ritesh ...

some problems of codes of MATLAB 7.0 working on MATLAB 6.5
I have used MATLAB for few hours.So I don't know the differences between version 6.5 and 7.0.I want to use some codes of MATLAB 7.0, but they doesn't work in MATLAB 6.5.How to change these codes so that they can work in matlab 6.5.Waiting for your help. Thank you . The codes are like this .I think changing the function findPI may work ,but I don'y know how % PIfun.m % Evaluate a function used to find the PI-line, using Kyle Champley's % method. % % Adam Wunderlich % last update: 5/18/06 function y = PIfun(r,R,h,gamma,x3,sb) temp = R - r*cos(gamma-sb); y = h*((pi - 2*atan(r*sin(gamma-sb)/temp))*(1 + (r^2 - R^2)/ (2*R*temp)) ... + sb) - x3; % find_PI_Line.m % % Find the the parametric interval corresponding to the unique PI-line % passing through the point x for a given helical pitch. % This code implements the method of Kyle Champley. % inputs: P = pitch (cm/turn), R = helix radius, delta_s = s stepsize, x % output: PI = [sb st] % % Adam Wunderlich % last update: 5/18/06 function [PI] = findPI(P,R,delta_s,x) h = P/(2*pi); r = sqrt(x(1)^2+x(2)^2); gamma = atan2(x(2),x(1)); options = optimset('TolX',h*delta_s/100,'FunValCheck','on'); [sb,fval,exitflag] = fzero(@(sb) PIfun(r,R,h,gamma,x(3),sb),... [(x(3)-h*pi)/h,x(3)/h],options); if exitflag ~=1, disp('Error: PI invalid'); end % note that beta=sb in Kyle's formula alphaX = atan(r*sin(gamma-sb)/(R - r*cos(gamma-sb))); st = sb + pi -...

Matlab engine with matlab R2010b
Hello All, I'm working with an aplication that use the matlab engine. I made the C++ program and it is working well in my pc with matlab 2007b, but the same very basic program shows an error when I tried to compile it in a pc with matlab R2010b. The error is about the icuuc32.dll. ¿Why is asking this DLL? How can I solve this?. Thanks¡ ...

Java to Matlab
How does one use Java classes that are added to the classpath ? Barney: > How does one use Java classes that are added to the classpath ? there's copious information at this great site: <http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_external/ch05matf.html#matlab_interface_to_java> us ...

Spawning matlab from within matlab
Hello all, I would like to spawn multiple matlab processes from an '.m' script. Meaning, run an m-file from a 'parent' Matlab that launches, say, 8 more 'children' matlab processes. I'd like to do it in such a way that the same m-file in the 'parent' is able to close down, or kill, all the 'children' processes. Any suggestions? Joe ...

Matlab problem!!
Dear All I hope that you are doing well and everything is OK. I have a question, please: I have a decimal number stored in a matrix. For example, Matrix subscripts: 1 2 3 5 6 7 8 9 10 Values: 8 9 8 7 7 9 9 2 7 So, the number is: 898779927 My matrix consists of 3000 cells and each cell contains a number from 0-9. I need to get the number of bits for this string in binary. However, I cannot convert it to binary as the program will give me out of range. Thanks and your response will be much appreciated. Sincerely, Kal kal wrote: > Dear All > I hope that you are doing well and everything is OK. > I have a question, please: > I have a decimal number stored in a matrix. For example, > Matrix subscripts: 1 2 3 5 6 7 8 9 > 10 > Values: 8 9 8 7 7 9 9 2 > 7 > So, the number is: 898779927 > My matrix consists of 3000 cells and each cell contains a number from > 0-9. I need to get the number of bits for this string in binary. > However, I cannot convert it to binary as the program will give me out > of range. > Thanks and your response will be much appreciated. I don't ordinarily do other's homework, but in the spirit of the season, I'll meet you more than half way. If you get "Out of range", then you're converting the wrong item. The correct answer is 30. D...

problem in matlab
Hello everybody . I have MAT LAB 2009 version software but it doesn't work properly in my system because in my system the RAM is 512 MB . when i started MAT LAB it takes lot of time in processing . Please any one provide me Mat lab software which is compatible to my system. On 1/4/2012 11:41 PM, siddhartha chandel wrote: > Hello everybody . I have MAT LAB 2009 version software but it doesn't work properly in my system >because in my system the RAM is 512 MB . when i started MAT LAB it >takes lot of time in processing . Please any one provide me Mat lab software which is compatible to my system. hi; First it is called Matlab (one word). As for the problem you are having, I do not think Mathworks makes a light version of Matlab, so only think I can suggest is to see if you can buy a little bit more RAM for your PC to make it run faster. "siddhartha chandel" <raman007.ec@gmail.com> wrote in message news:je3d5k$91m$1@newscl01ah.mathworks.com... > Hello everybody . I have MAT LAB 2009 version software but it doesn't work > properly in my system because in my system the RAM is 512 MB . when i > started MAT LAB it takes lot of time in processing . Please any one > provide me Mat lab software which is compatible to my system. For releases R2009a and R2009b, the bare minimum requirement given in the system requirements for running MATLAB on a 32-bit system is 512 MB of memory, while 1024 MB is recommended. [If you'...

slow optimization using nonlcon with GA within matlab toolbox and mixed integer problem using GA within Matlab
greeting all, i'm using nonlcon(nonlinear inequality constraint) with GA from the toolbox provided by matlab. does anyone notice the extreme slowlness in evaluating nonlinear constraint as compared to other linear constraint? my problem for nonlinear constraint is as follow c(1)=x+y^2-2*ones(N,1) where x and y are Nx1 vector. which means if N increases, the size of constraint increases. and to clarify, the min problem is sometime like min c'z where z=[x;y], which means x and y are some range of variable within z(just a matter of problem formulation) well, is there anyone with other alternative or is it possible or method in including non-linear constraint directly to fitness function? (well, actually nonlcon deals nonlinear constraint by using Augmented Lagrangian Pattern Search from what i see from the help file, or am i wrong?) and one more question, is there anyone that attempt to attempt to apply mixed integer problem into the GA in matlab? For now, i can only switch before pure integer or pure real number problem, but not mixed at the moment. I will be trying to add in some repair operator to fix up the variable that needs to be integer and other remaining in real number. I'm not sure why you are using ga to solve your problem. Did you find fmincon unsatisfactory in any way? Alan Weiss MATLAB mathematical toolbox documentation On 5/10/2011 11:53 PM, terry wrote: > greeting all, > > i'm using nonlcon(nonlinear inequality constraint)...

embedded matlab function MATLAB R2009a
I downloaded the MS visual C++ 2008 Express Edition and the SDK as detailed in http://www.mathworks.com/support/solutions/en/data/1-6IJJ3L/?solution=1-6IJJ3L My embedded function didnt work at the beginning because I did "mex -setup" before I installed my SDK. But after I installed the SDK, I ran "mex -setup" in Matlab once again and choose the MS visual C++2008 as my compiler. Then, my embedded matlab function worked. Thanks to the contribution from above! ...

Creating DLL in Matlab and using them in Matlab?
Hi, is it possible to create dll in Matlab and then using it in other Matlab apllication? I've made a simple function and put it into dll. But when I try to use this library in other apllication written in matlab it doesn't works. Any idea? -- Pozdrawiam, e-Shrek hi e-shresk, I once created a matlab dll, and called it in c code. it worked. I guess you have to check whether you dll was built correctly or not. ps. why don't u call matlab function directly? Dnia Mon, 26 Oct 2009 07:19:04 +0000 (UTC), Jun napisa�(a): > hi e-shresk, > > I once created a matlab dll, and called it in c code. it worked. Hmmm. The function is very simple: ========================== function var_o = testlib(var_i) if var_i == '1', var_o = 'jest'; else var_o = 'brak'; end ========================== Compilation: mcc -W lib:xlib -T link:lib testlib After it, I have *.dll *.lib *.h Tryin' to load library: loadlibrary('xlib.dll','xlib.h'); The result is: Warning: Warnings messages were produced while parsing. Check the functions you intend to use for correctness. Warning text can be viewed using: [notfound,warnings]=loadlibrary(...) > In loadlibrary at 394 Where is the problem? > ps. why don't u call matlab function directly? I have a pack of functions that I wouldlike to use with few different matlab compiled programs. -- Pozdrawiam, e-Shrek On Oct 26, 1:47=A0pm, e-Shrek <e-Shrek.wyt...@wytni...

problem with parallel matlab
for i=1:size(APLocation,1) point=APLocation(i,:); parfor j=1:length (RXpoint) rssi(i,j) = LOSS(point,RXpoint(:,j)'); %%rssi having the signal strength from all AP's end end when i'm running the following code, i get the same value for each element of rssi (serially i get different results) where is my problem? Creating some fake data and and implementing a simple LOSS function, I do not see a different between the serial and parallel execution. Does LOSS use any persistent or global variables? function [ rssi rssi2 ] = foo APLocation = rand(10); RXpoint = rand(10) * 5; for i=1:size(APLocation,1) point=APLocation(i,:); parfor j=1:length (RXpoint) rssi(i,j) = LOSS(point,RXpoint(:,j)'); end end for i=1:size(APLocation,1) point=APLocation(i,:); for j=1:length (RXpoint) rssi2(i,j) = LOSS(point,RXpoint(:,j)'); end end end function rv = LOSS( a,b ) rv = sum( a+b ); end "michael" <bezenchu@gmail.com> wrote in message news:ht0t0k$fce$1@fred.mathworks.com... > for i=1:size(APLocation,1) > point=APLocation(i,:); > parfor j=1:length (RXpoint) > rssi(i,j) = LOSS(point,RXpoint(:,j)'); %%rssi having the signal > strength from all AP's > end > end > > when i'm running the following code, i get the same value for each element ...

LMI Problem in MatLab
Hello, I'm sort of a new user to MATLAB and am in need of help. I'd appreciate any advice anyone could give me. My problem is as followed: In the steady space dx/dt=(a-b*f)x by using the LMI method, I want to find the Vector 'f'. How can define the LMI in MATLAB and solve for it. Thanks in advance. Regards, Milad ...

Problems with DLL from Matlab
Dear Community I wrote a DLL using Microsoft VisualC++ 2005 which exports two functions which I wanted to use in Matlab. If now in Matlab I enter: >> loadlibrary('MandelDLL.dll', 'MandelDLL.h') >> libfunctions('MandelDLL.dll') No methods for class lib.MandelDLL.dll or no class lib.MandelDLL.dll. (both files are in my work directory) I'm not so familiar with visual C++... At least QuickView from old NT 4.0 shows me the exported functions... Best regards Pascal -- Visual C++ files -- - MandelDLL.cpp - #include "stdafx.h" #include "math.h" extern "C" { struct MandelBild { int pixels[600][600]; }; __declspec(dllexport) int CalculateMandelbrot(double posX, double posY, double width, double height, MandelBild &myMandelBild); __declspec(dllexport) int incrementNumber(int i); } __declspec(dllexport) int incrementNumber(int i) { return i+1; } __declspec(dllexport) int CalculateMandelbrot(double posX, double posY, double width, double height, MandelBild &myMandelBild) { const int diagramWidth = 600; const int diagramHeight = 600; const int maxIt = 250; int redColorFactor = 121; int blueColorFactor = 7; int greenColorFactor = 0; int i=0; int j=0; int temp=0; const double maxAbsSqr = 4; double x_alt = 0; double x_neu = 0; double y_alt = 0; double y_neu = 0; double c_x = 0; double c_y = 0; int iteration = 0; int iOuterCounter = 0; int iInnerCounter...

problem with matlab function
Hello, I am using a matlab function "vitdec" to simulate viterbi decoding i awgn channel. I noticed a rather weird problem with it. When I increase th msglength the BER improves(eventually plateaus down), my understanding i that BEr improves with the traceback length. Attached is the matlab cod and the BERs I observed, traceback length was fixed to 15 for a constrain length of 3. Is there something wrong i am doing or is there a problem wit vitdec? your help will be greatly appreciated. Thanks ***************************************************************************** msglen: 15, 30, 300, 3000, 30000 BER: 2.1e-3, 8.2e-4, 1.5e-4, 9.5e-5, 8.7e-5 **************************************************************************** Matlab Code clear all snr=4; k=3;%constraint length msglen=30000;%msg length tblen=15;%traceback length for snr_idx=1:length(snr) p=sqrt(0.5)*(10^(-1*snr(snr_idx)/20)); no_bit_errors=0;no_bits=0; while no_bit_errors<100 msg = randint(1,msglen); % Random data t = poly2trellis(k,[7 5]); % Define trellis. [code fstate] = convenc(msg,t,0); % Encode the data. noise=p*randn(1,2*msglen); inp_bit=2*code-1; rec_bit=inp_bit+noise; [hrdout]= vitdec( (rec_bit>0), t, tblen, 'trunc', 'hard' ); no_bit_errors=no_bit_errors+sum(abs(msg-hrdout)); no_bits=no_bits+length(msg); end BER(snr_idx)=no...

problem matlab comunication
I'm trying tu comunicate two hosts with matlab and when I had used the function 'fscanf' appears this warning: Warning: A timeout occurred before the Terminator was reached and ans = ' ' someone could help me to sove the problem? thanks diego wrote: > I'm trying tu comunicate two hosts with matlab and when I had used the > function 'fscanf' appears this warning: > Warning: A timeout occurred before the Terminator was > reached > and ans = ' ' > someone could help me to sove the problem? Make sure that the line terminator is the same on both sides, and make sure that the other side is really sending the line terminator, and make sure that the other side is flushing its buffer after constructing the character string to send. On unix-type systems, the line terminator is alway just the newline character (control-J, character value decimal 10). On Windows systems when the object is open in binary mode, the line terminator is the newline character like above. On Windows systems when the object is open in text mode, the line terminator is the character pair of newline followed by carriage return, decimal 10 then decimal 13. With regards to flushing the buffer: either the other end has to be sending without any buffering at all (e.g., have opened the port using the C open() call instead of fopen(), and sends characters using putchar() or putc(), instead of fputs() or fwrite); if the other end is using bufferin...

MATLAB with YALMIP Problem
Hi All, I have trying to solve a huge problem and need to parallelize my computations desperately. I am using MATLAB 7.12.0 for my task and I have installed Yalmip with Sedumi 1.3 as a solver. I have the code below which does not work in parfor loop but the code says that it has Transparency problem in evalin. However, I checked here http://www.mathworks.com/matlabcentral/newsreader/view_thread/277938 No such problem about transparency is mentioned. Moreover, I have also done everything that has been said in the previous post. Can anyone kindly tell me as to what is the problem with my code? I am using Linux. parfor j=1:233956, yalmip('clear'); str = int2str ( j ); string = '/data/word_coordinates/'; str1 = '/data/scores/'; str1= strcat ( str1 , j ); fd = fopen ( str1 , 'w' ); str=strcat(string,str); file_coordinate_word = strcat ( str , '.wcor' );%this will be the .dic files if ( exist(file_coordinate_word,'file') == 0 ) continue end coordinate_vectors=dlmread(file_coordinate_word); numlines=length(coordinate_vectors); W=zeros(numlines,200); for coordinates=1:numlines, W(coordinates,1:200)=term_vectors(coordinate_vectors(coordinates),:); end D=document_vectors(j,:); b=sdpvar(1,numlines); e=ones(1,numlines,1); Constraints=[0<=b<=1,(b*e')==1]; solvesdp(Constraints,[],norm(D-b*W,2)); fprintf (fd ,'%d ...

A hard problem in matlab
passing gradient when using fminunc I am trying to make use of the gradient of the function and then minimize using fminunc in an unconstrained problem. I have done as specified by the help file (incorporating optimset and all that) but an error is being generated. If i don't pass the gradient it find the minimum using a line search instead of trust region method. I list the error message below. Any help is appreciated. function[f,g]=3Dexam1(x) %r=3D10=E5=BC=80=E5=A7=8B; M=3D10; r=3D1000000; f=3Dlog(x(1))-x(2)+r*((-x(1)+1+abs(-x(1)+1))/2)^2+r*(x(1)^2+x(2)^2-4)^2; %g(1)=3Ddiff(f,x(1)); %g(2)=3Ddiff(f,x(2)); g(1)=3D1/x(1)+r*2*(-1/2*x(1)+1+1/2*abs(x(1)-2))*(-1/2+1/2*sign(x-2)) +r*2*(x(1)^2+x(2)^2-4)*2*x(1); g(2)=3D-1+r*2*(x(1)^2+x(2)^2-4)*2*x(2); >> options=3Doptimset('GradObj','on');[x,fval]=3Dfminunc('exam1',[1;0],opti= ons) ??? In an assignment A(I) =3D B, the number of elements in B and I must be the same. Error in =3D=3D> exam1 at 8 g(1)=3D1/x(1)+r*2*(-1/2*x(1)+1+1/2*abs(x(1)-2))*(-1/2+1/2*sign(x-2)) +r*2*(x(1)^2+x(2)^2-4)*2*x(1); Error in =3D=3D> fminunc at 220 [f,GRAD(:)] =3D feval(funfcn{3},x,varargin{:}); >> On 5/5/2012 9:52 AM, wangbin123ab@126.com wrote: .... > ??? In an assignment A(I) = B, the number of elements in B and > I must be the same. > > Error in ==> exam1 at 8 > g(1)=1/x(1)+r*2*(-1/2*x(1)+1+1/2*abs(x(1)-2))*(-1/2+1/2*sign(x-2)) ...

Matlab problem #19
Hello, I'm new to Matlab and my school gave me an assignment. Unfortunately, I dont have any clue how to solve this. Can anybody help me? "One carton of milk contains 650 Milliliter. Make a MatLab file in which the number of cartons needed to fill up a bath will be calculated after giving the volume of the bad (liter). It is not possible to use (for instance) 104.53 cartons. Only round numbers are allowed." On Feb 19, 11:37=A0am, Mike <Campb...@trash2009.com> wrote: > Hello, > > I'm new to Matlab and my school gave me an assignment. > Unfortunately, I dont have any clue how to solve this. Can anybody help m= e? > > "One carton of milk contains 650 Milliliter. > > Make a MatLab file in which the number of cartons needed to fill up a bat= h will be calculated after giving the volume of the bad (liter). > > It is not possible to use (for instance) 104.53 cartons. Only round numbe= rs are allowed." How would you do this mathematically, first? If you can give me an example that shows that you know what you are doing, I can help provide the code that will do what you do on paper. -Nathan Mike Vriezema wrote: > Like Y =3D 0.65 =C3=97 X >=20 > with Y =3D volume > and X =3D the number of cartons >=20 > Something like this I think Suppose each carton contained 1/2 litre, and the bath could hold 10 litre= s.=20 Your solution would predict that you would need 1/2 * 10 =3D 5 cartons. But 5 car...

Matlab UI problem
I am using guide to create a user interface. Amongst other components on the UI I have an axes component, which I am using imshow on to display an image. Is there a way that when the user presses the mouse on the axes I get the coordinate of the image where the user clicked? Thanks On 12/7/2011 3:50 AM, Aron Sceidt wrote: > I am using guide to create a user interface. Amongst other components on the UI I >have an axes component, which I am using imshow on to display an image. Is >there a way that when the user presses the mouse on the axes I get the >coordinate of the image where the user clicked? > > Thanks not sure about the 'image' bit. But you can try [X,Y] = GINPUT(N) gets N points from the current axes and returns the X- and Y-coordinates --Nasser Thanks Nasser, my problem however is that the axes is inside a UI amongst other components. I want to create a sort of method that when the user clicks somewhere on those axes (and not anywhere else on the UI) I get the point of the image.. Not sure if I am making myself clear enough. Thanks "Nasser M. Abbasi" <nma@12000.org> wrote in message <jbndqc$oaq$1@speranza.aioe.org>... > On 12/7/2011 3:50 AM, Aron Sceidt wrote: > > I am using guide to create a user interface. Amongst other components on the UI I > >have an axes component, which I am using imshow on to display an image. Is > >there a way that when the user presses the mouse on the axe...

Matlab Upgrading Problem
Hi all, We upgraded our MATLAB from R2007b to R2009a, and also the xPCTarget to 4.1. After upgrading, we are encountering the following problems when building simulink model: Open Watcom Make Version 1.3 Portions Copyright (c) 1988-2002 Sybase, Inc. All Rights Reserved. Source code is available under the Sybase Open Watcom Public License. See http://www.openwatcom.org/ for details. Error(F10): Macros nested too deep Warning(W79): Makefile may be Microsoft; try /ms switch Error(E02): Make execution terminated E:\Task\MATLAB\UCBSim&Exp V3.0\M16iBExperimentor_xpc_rtw>echo The make command returned an error of 4 The make command returned an error of 4 E:\Task\MATLAB\UCBSim&Exp V3.0\M16iBExperimentor_xpc_rtw>An_error_occurred_during_the_call_to_make 'An_error_occurred_during_the_call_to_make' is not recognized as an internal or external command, operable program or batch file. Can anyone kindly tell me that if we are missing anything during the upgrading? Thanks, Cong Wang ------------------------ PhD Student Mechanical Systems Control Lab UC Berkeley Hi Cong Wang, It's been a little while since this post, but I encountered this same issue today. In my case, the error was due to using an old version of the WATCOM compiler. In R2007b the supported version of WATCOM was 1.3, however R2009b requires WATCOM 1.7 as stated here: http://www.mathworks.com/support/compilers/R2009b/ After downloading version 1.7 from the WATCOM site (...

Web resources about - Problems with Java from Matlab - comp.soft-sys.matlab

Is–ought problem - Wikipedia, the free encyclopedia
The is–ought problem in meta-ethics as articulated by Scottish philosopher and historian David Hume (1711–76) is that many writers make claims ...

Volkswagen e-Golfs stall due to battery software problem, recall announced
... Volkswagen will recall the 5,561 e-Golf electric vehicles that it’s sold in the US since November 2014 due to a battery software problem, the ...

FormFactor Drops 10%: Stifel Cuts to Hold, Summit Defends; ‘High-Class Problem’
... Nicolaus ’s Patrick Ho , who cut his rating on the shares to Hold From Buy, and stripped away his $11 price target, writing that the problem ...

"All we need to do is change our 'frame' for terrorism and start treating it as a medical problem."
... terribly unfair – just to avoid contact with the 1% who might be infected with the radical islamic terror virus. Trump is approaching the problem ...

Microsoft's HoloLens has a surprising heat problem
The Microsoft HoloLens holographic goggles may not be comfortable to wear for long periods of time, warns game developer David Dedeine in an ...

Google’s Alphabet has a CEO problem
A trio of developments have emerged in the last two weeks underscoring this tension. Re/code reports.

Obama to address nation's growing opioid problem
ATLANTA (AP) — The Obama administration will issue a proposed rule Tuesday that aims to increase medication-based treatment for tens of thousands ...

Trump: ‘My Biggest Problems Are Repeats And Retweets’
Cooper: 'Well maybe you should learn from your behavior and not retweet things'

Antonio Brown Had Some Boner Problems While Training For Dancing With The Stars
Steelers wide receiver Antonio Brown is a contestant on this season of Dancing With The Stars , and he made it through the latest round of cuts ...

Mickos on Security: Tech Is the Problem, People Are the Solution
Former MySQL Marten Mickos, now CEO of security vendor HackerOne, admits to a security debt that open-source must now pay.

Resources last updated: 3/31/2016 5:12:26 AM