Table of Contents
IncludingStartup Options in a Shortcut on Windows Systems" >IncludingStartup Options in a Shortcut on Windows Systems
SpecifyingStartup Options in the MATLAB Startup File" >SpecifyingStartup Options in the MATLAB Startup File
CommonlyUsed Startup Options" >CommonlyUsed Startup Options
PassingPerl Variables on Startup" >PassingPerl Variables on Startup
Startupand Calling Java Software from the MATLAB Program" >Startupand Calling Java Software from the MATLAB Program
RunningMATLAB without graphic interface" >RunningMATLAB without graphic interface
Interactiveover SSH" >Interactiveover SSH
Runninga MATLAB script over SSH" >Runninga MATLAB script over SSH
Runninga MATLAB script with input variables over SSH" >Runninga MATLAB script with input variables over SSH
OnSun Grid Engine (SGE)-powered cluster" >OnSun Grid Engine (SGE)-powered cluster
Home Backend Development PHP Tutorial 施用php在网页执行matlab

施用php在网页执行matlab

Jun 13, 2016 am 10:46 AM
matlab nbsp quot startup the

使用php在网页执行matlab

通过php调用linux命令,可以实现远程调用matlab.

试验环境:Fedora16, matlab2012b linux version, Google chrome 18.0.1025.108 beta

以下代码实现了在网页输入matlab命令并显示执行结果。注意:如果不加-nodisplay选项,会出现" no display specified"的警告,当然可以在执行matlab命令之前unset DISPLAY也可以直接在terminal执行matlab。

如果你仅仅想远程调用matlab函数,可以参考mathworks的php webservice相关文档,此处也可以参考官方关于python调用的文档。

以下代码对于plot()等绘图命令会出现{Warning: Objects of graph2d.lineseries class exist - not clearing this class or any of its super-classes}错误,目前未解决(也就是无法绘图)。但是通过ssh远程登陆服务器调用相同命令可以plot并save图像,不解。

            
Copy after login
输入命令:
";//$command="/usr/local/MATLAB/R2012a/bin/matlab -r "."\"".$cmd."\"";shell_exec("unset DISPLAY");//删除DISPLAY环境变量$out = shell_exec($command);$str=" Copyright 1984-2012 The MathWorks, Inc. R2012a (7.14.0.739) 32-bit (glnx86) February 9, 2012 To get started, type one of these: helpwin, helpdesk, or demo.For product information, visit www.mathworks.com.";$out=ltrim($out,$str);$out=rtrim($out,">>");echo $out;}?>

相关截图:                                                                                                                                                                                                                                                                                            

输入sin(1:10)进行简单计算


输入ver命令获取版本信息

直接终端运行



参考资料:                                                                                                                                                                                                                                                                                             

mathwork关于matlab启动参数的介绍

http://www.mathworks.cn/help/techdoc/matlab_env/f8-4994.html

SpecifyingMATLAB Startup Options

Youcan specify startup options (also called command flags or commandline switches) that instruct the MATLAB program to perform certainoperations when you start it. On all platforms, you specify theoptions as arguments to the matlab command when you start is at theoperating system prompt. For example, the following starts MATLAB andsuppresses the display of the splash screen.

matlab-nosplash

OnWindows platforms, you can precede a startup option with either ahyphen (-) or a slash (/). For example, -nosplash and /nosplash areequivalent.

Onall platforms, you can also specify startup options using a MATLABstartup file—see Specifying Startup Options in the MATLAB StartupFile

OnWindows platforms, you can specify startup options in the MATLABshortcut—see Including Startup Options in a Shortcut on WindowsSystems.

IncludingStartup Options in a Shortcut on Windows Systems

Youcan add selected startup options (also called command flags orswitches for the command line) to the target path for your shortcutin the Windows environment for MATLAB. For more information about theoptions, see CommonlyUsed Startup Options.

Touse startup options for the MATLAB shortcut icon in a Windowsenvironment, follow these steps:

  1. Right-clickthe shortcut icon for MATLAB  andselect Properties from the context menu. TheProperties dialog box for MATLAB opens to the Shortcut pane.

  2. Inthe Target field,after the target path for matlab.exe,add the startup option, and click OK.For example, adding -r"filename" runsthe MATLAB code file filenameafterstartup.

Thisexample instructs MATLAB to automatically run the file results afterstartup, whereresults.m isin the startup folder or on the search path for MATLAB. The statementin the Target fieldmight appear as

<span style="color:#000000"><span style="font-family:courier new,courier,monospace">C:\Program Files\MATLAB\R2010b\bin\matlab.exe -r "results"</span></span>
Copy after login

Includethe statement in double quotation marks ("statement").Use only the file name, not the file extension or path name. Forexample, MATLAB produces an error when you run

<span style="color:#000000"><span style="font-family:courier new,courier,monospace">... matlab.exe -r "D:\results.m"</span></span>
Copy after login

Usesemicolons or commas to separate multiple statements. This examplechanges the format to short,and then runs the MATLAB code file results:

<span style="color:#000000"><span style="font-family:courier new,courier,monospace">... matlab.exe -r "format('short');results"</span></span>
Copy after login

Separatemultiple options with spaces. This example starts MATLAB withoutdisplaying the splash screen, and then runs the MATLAB codefile results:

<span style="color:#000000"><span style="font-family:courier new,courier,monospace">... matlab.exe -nosplash -r "results"</span></span>
Copy after login

SpecifyingStartup Options in the MATLAB Startup File

Atstartup, MATLAB automatically executes the file matlabrc.m and,if it exists,startup.m.The file matlabrc.m,which is in the matlabroot/toolbox/local folder,is reserved for use by MathWorks and by the system manager onmultiuser systems.

Thefile startup.m isfor you to specify startup options. For example, you can modify thedefault search path, predefine variables in your workspace, or definedefaults for Handle Graphics? objects.Use the following statements in a startup.m fileto add the specified folder, /home/username/mytools,to the search path, and to change the current folder to mytools uponstartup.

<span style="font-family:DejaVu Sans Mono,monospace"><span style="font-family:'courier new',courier,monospace"><span style="font-size:9pt">addpath /home/</span></span><tt class="western"><span style="font-family:'courier new',courier,monospace"><span style="font-size:9pt"><em>username</em></span></span></tt><span style="font-family:'courier new',courier,monospace"><span style="font-size:9pt">/mytools</span></span></span><span style="font-family:DejaVu Sans Mono,monospace"><span style="font-family:'courier new',courier,monospace"><span style="font-size:9pt">cd /home/</span></span><tt class="western"><span style="font-family:'courier new',courier,monospace"><span style="font-size:9pt"><em>username</em></span></span></tt><span style="font-family:'courier new',courier,monospace"><span style="font-size:9pt">/mytools</span></span></span>
Copy after login
<span style="font-size:9pt; font-family:'Times New Roman',serif"><span style="font-family:Verdana,Arial,Helvetica,sans-serif"><span style="font-size:9pt">Placethe </span></span></span><tt class="western" style="font-size:9pt"><span style="font-family:'courier new',courier,monospace"><span style="font-size:9pt">startup.m</span></span></tt><span style="font-size:9pt; font-family:'Times New Roman',serif"><span style="font-family:Verdana,Arial,Helvetica,sans-serif"><span style="font-size:9pt"> filein the default or current startup folder, which is where MATLAB firstlooks for it. For more information, see .</span></span></span>
Copy after login

CommonlyUsed Startup Options

Thefollowing table provides a list of some commonly used startup optionsfor both Windows and UNIX? platforms.For more information, including a complete list of startup options,see the matlab(Windows) referencepage or the matlab(UNIX) referencepage.

Platform

Option

Description

All

-clicensefile

Set LM_LICENSE_FILE to licensefile.It can have the form [email protected].

All

-hor -help

Displaystartup options (without starting MATLAB).

All

-logfile"logfilename"

Automaticallywrite output from MATLAB to the specified log file.

Windowsplatforms

-minimize

StartMATLAB with the desktop minimized. Any desktop tools or documentsthat were undocked when MATLAB was last closed will not beminimized upon startup.

UNIXplatforms

-nojvm

StartMATLAB without loading the Sun Microsystems JVM? software. Thisminimizes memory usage and improves initial startup speed, butrestricts functionality. With nojvm,you cannot use the desktop, figures, or any tools that requireJava software.

Forexample, you cannot set preferences if you start MATLAB withthe -nojvm option.However, you can start MATLAB once without the -nojvm option,set the preference, and quit MATLAB. MATLAB remembers thatpreference when you start it again, even if you usethe-nojvm option.

All

-nosplash

StartMATLAB without displaying its splash screen.

All

-r"statement"

Automaticallyrun the specified statement immediately after MATLAB starts. Thisis sometimes referred to as calling MATLAB in batch mode. Filesyou run must be in the startup folder for MATLAB or on the searchpath. Do not include path names or file extensions. Enclose thestatement in double quotation marks ("statement").Use semicolons or commas to separate multiple statements

All

-singleCompThread

LimitMATLAB to a single computational thread. By default, Windowsmakes use of the multithreading capabilities of the computer onwhich it is running.


PassingPerl Variables on Startup

Youcan pass Perl variables to MATLAB on startup by usingthe -r optionof the matlabfunction.For example, assume a MATLAB function test thattakes one input variable:

<span style="color:#000000"><span style="font-family:courier new,courier,monospace">function test(x)</span></span>
Copy after login

Tostart MATLAB with the function test,use the command

<span style="color:#000000"><span style="font-family:courier new,courier,monospace">matlab -r "test(10)"</span></span>
Copy after login
Copy after login

Onsome platforms, you might need to use double quotation marks:

<span style="color:#000000"><span style="font-family:courier new,courier,monospace">matlab -r "test(10)"</span></span>
Copy after login
Copy after login

Thiscommand starts MATLAB and runs test withthe input argument 10.

Topass a Perl variable instead of a constant as the input parameter,follow these steps.

  1. Createa Perl script such as

    <span style="color:#000000"> <span style="font-family:DejaVu Sans Mono,monospace"><span style="font-family:courier new,courier,monospace"><span style="font-size:12px; font-size:9pt">#!/usr/local/bin/perl</span></span></span></span><span style="color:#000000"> <span style="font-family:DejaVu Sans Mono,monospace"><span style="font-family:courier new,courier,monospace"><span style="font-size:12px; font-size:9pt">$val = 10; </span></span></span></span><span style="color:#000000"> <span style="font-family:DejaVu Sans Mono,monospace"><span style="font-family:courier new,courier,monospace"><span style="font-size:12px; font-size:9pt">system('matlab -r "test(' . ${val} . ')"');</span></span></span></span>
    Copy after login
  2. Invokethe Perl script at the prompt using a Perl interpreter.

Formore information, see the matlab(Windows) or matlab(UNIX) referencepage.

Startupand Calling Java Software from the MATLAB Program

Whenthe MATLAB program starts, it constructs the class path for SunMicrosystems Java software using librarypath.txt aswell as classpath.txt.If you call Java software from MATLAB, see more about this in TheJava Class Path and LocatingNative Method Libraries inthe MATLAB External Interfaces documentation.


===============================================================================================================================

http://narnia.cs.ttu.edu/drupal/node/41

RunningMATLAB without graphic interface

Interactiveover SSH

StartMATLAB using the command:

<span style="color:#222222"><span style="font-family:Helvetica,sans-serif"><span style="font-size:12px">matlab -nodisplay -nojvm</span></span></span>
Copy after login

Runninga MATLAB script over SSH

Inthis case, you don't even need a MATLAB Prompt to interact with.

<span style="color:#222222"><span style="font-family:Helvetica,sans-serif"><span style="font-size:12px">matlab -nodisplay -nojvm -r a_code > matlab.out</span></span></span>
Copy after login

YourMATLAB program should have the file name <span style="color:#222222"><span style="font-family:Helvetica,sans-serif"><span style="font-size:12px; font-size:10pt">a_code.m</span></span></span> (youcan change it to whatever name you like. But when you tell MATLAB torun it, omit the <span style="color:#222222"><span style="font-family:Helvetica,sans-serif"><span style="font-size:12px; font-size:10pt">.m</span></span></span> suffix.)The <span style="color:#222222"><span style="font-family:Helvetica,sans-serif"><span style="font-size:12px; font-size:10pt">>matlab.out</span></span></span> partredirects the output to a file rather than showing on your Linux/MacOS X terminal. This way is preferred because you have a record onwhat is happening.

Runninga MATLAB script with input variables over SSH

First,go to the directory containing the MATLAB script that defines thefunction (or, fancier, add that directory into MATLAB PATH byediting your MATLABPATH environment variable or pathdef.m file).Then, run like this

<span style="color:#222222"><span style="font-family:Helvetica,sans-serif"><span style="font-size:12px">matlab -nodisplay -nojvm -r "my_function(10)"</span></span></span>
Copy after login

Again,you can redirect the output to a file.

Youcan also write a Shell, Perl or Python script to do so. MATLAB givesan example using Perlat http://www.mathworks.com/help/techdoc/matlab_env/f8-4994.html

OnSun Grid Engine (SGE)-powered cluster

Writea job script below and submit it using <span style="color:#222222"><span style="font-family:Helvetica,sans-serif"><span style="font-size:12px; font-size:10pt">qsub</span></span></span>

<span style="color:#222222"><span style="font-family:Helvetica,sans-serif"><span style="font-size:12px">#!/bin/sh</span></span></span><span style="color:#222222"><span style="font-family:Helvetica,sans-serif"><span style="font-size:12px">#$ -V</span></span></span><span style="color:#222222"><span style="font-family:Helvetica,sans-serif"><span style="font-size:12px">#$ -cwd</span></span></span><span style="color:#222222"><span style="font-family:Helvetica,sans-serif"><span style="font-size:12px">#$ -S /bin/bash</span></span></span><span style="color:#222222"><span style="font-family:Helvetica,sans-serif"><span style="font-size:12px">#$ -N matlab</span></span></span><span style="color:#222222"><span style="font-family:Helvetica,sans-serif"><span style="font-size:12px">#$ -o $JOB_NAME.o$JOB_ID</span></span></span><span style="color:#222222"><span style="font-family:Helvetica,sans-serif"><span style="font-size:12px">#$ -e $JOB_NAME.e$JOB_ID</span></span></span><span style="color:#222222"><span style="font-family:Helvetica,sans-serif"><span style="font-size:12px">#$ -q normal </span></span></span><span style="color:#222222"><span style="font-family:Helvetica,sans-"></span></span>
Copy after login
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Solution: Your organization requires you to change your PIN Solution: Your organization requires you to change your PIN Oct 04, 2023 pm 05:45 PM

The message "Your organization has asked you to change your PIN" will appear on the login screen. This happens when the PIN expiration limit is reached on a computer using organization-based account settings, where they have control over personal devices. However, if you set up Windows using a personal account, the error message should ideally not appear. Although this is not always the case. Most users who encounter errors report using their personal accounts. Why does my organization ask me to change my PIN on Windows 11? It's possible that your account is associated with an organization, and your primary approach should be to verify this. Contacting your domain administrator can help! Additionally, misconfigured local policy settings or incorrect registry keys can cause errors. Right now

How to adjust window border settings on Windows 11: Change color and size How to adjust window border settings on Windows 11: Change color and size Sep 22, 2023 am 11:37 AM

Windows 11 brings fresh and elegant design to the forefront; the modern interface allows you to personalize and change the finest details, such as window borders. In this guide, we'll discuss step-by-step instructions to help you create an environment that reflects your style in the Windows operating system. How to change window border settings? Press + to open the Settings app. WindowsI go to Personalization and click Color Settings. Color Change Window Borders Settings Window 11" Width="643" Height="500" > Find the Show accent color on title bar and window borders option, and toggle the switch next to it. To display accent colors on the Start menu and taskbar To display the theme color on the Start menu and taskbar, turn on Show theme on the Start menu and taskbar

How to change title bar color on Windows 11? How to change title bar color on Windows 11? Sep 14, 2023 pm 03:33 PM

By default, the title bar color on Windows 11 depends on the dark/light theme you choose. However, you can change it to any color you want. In this guide, we'll discuss step-by-step instructions for three ways to change it and personalize your desktop experience to make it visually appealing. Is it possible to change the title bar color of active and inactive windows? Yes, you can change the title bar color of active windows using the Settings app, or you can change the title bar color of inactive windows using Registry Editor. To learn these steps, go to the next section. How to change title bar color in Windows 11? 1. Using the Settings app press + to open the settings window. WindowsI go to "Personalization" and then

OOBELANGUAGE Error Problems in Windows 11/10 Repair OOBELANGUAGE Error Problems in Windows 11/10 Repair Jul 16, 2023 pm 03:29 PM

Do you see "A problem occurred" along with the "OOBELANGUAGE" statement on the Windows Installer page? The installation of Windows sometimes stops due to such errors. OOBE means out-of-the-box experience. As the error message indicates, this is an issue related to OOBE language selection. There is nothing to worry about, you can solve this problem with nifty registry editing from the OOBE screen itself. Quick Fix – 1. Click the “Retry” button at the bottom of the OOBE app. This will continue the process without further hiccups. 2. Use the power button to force shut down the system. After the system restarts, OOBE should continue. 3. Disconnect the system from the Internet. Complete all aspects of OOBE in offline mode

How to enable or disable taskbar thumbnail previews on Windows 11 How to enable or disable taskbar thumbnail previews on Windows 11 Sep 15, 2023 pm 03:57 PM

Taskbar thumbnails can be fun, but they can also be distracting or annoying. Considering how often you hover over this area, you may have inadvertently closed important windows a few times. Another disadvantage is that it uses more system resources, so if you've been looking for a way to be more resource efficient, we'll show you how to disable it. However, if your hardware specs can handle it and you like the preview, you can enable it. How to enable taskbar thumbnail preview in Windows 11? 1. Using the Settings app tap the key and click Settings. Windows click System and select About. Click Advanced system settings. Navigate to the Advanced tab and select Settings under Performance. Select "Visual Effects"

Display scaling guide on Windows 11 Display scaling guide on Windows 11 Sep 19, 2023 pm 06:45 PM

We all have different preferences when it comes to display scaling on Windows 11. Some people like big icons, some like small icons. However, we all agree that having the right scaling is important. Poor font scaling or over-scaling of images can be a real productivity killer when working, so you need to know how to customize it to get the most out of your system's capabilities. Advantages of Custom Zoom: This is a useful feature for people who have difficulty reading text on the screen. It helps you see more on the screen at one time. You can create custom extension profiles that apply only to certain monitors and applications. Can help improve the performance of low-end hardware. It gives you more control over what's on your screen. How to use Windows 11

10 Ways to Adjust Brightness on Windows 11 10 Ways to Adjust Brightness on Windows 11 Dec 18, 2023 pm 02:21 PM

Screen brightness is an integral part of using modern computing devices, especially when you look at the screen for long periods of time. It helps you reduce eye strain, improve legibility, and view content easily and efficiently. However, depending on your settings, it can sometimes be difficult to manage brightness, especially on Windows 11 with the new UI changes. If you're having trouble adjusting brightness, here are all the ways to manage brightness on Windows 11. How to Change Brightness on Windows 11 [10 Ways Explained] Single monitor users can use the following methods to adjust brightness on Windows 11. This includes desktop systems using a single monitor as well as laptops. let's start. Method 1: Use the Action Center The Action Center is accessible

How to Fix Activation Error Code 0xc004f069 in Windows Server How to Fix Activation Error Code 0xc004f069 in Windows Server Jul 22, 2023 am 09:49 AM

The activation process on Windows sometimes takes a sudden turn to display an error message containing this error code 0xc004f069. Although the activation process is online, some older systems running Windows Server may experience this issue. Go through these initial checks, and if they don't help you activate your system, jump to the main solution to resolve the issue. Workaround – close the error message and activation window. Then restart the computer. Retry the Windows activation process from scratch again. Fix 1 – Activate from Terminal Activate Windows Server Edition system from cmd terminal. Stage – 1 Check Windows Server Version You have to check which type of W you are using

See all articles